virt_test/bin/python testrunner/runner.py --logfile=testrun.log --config=pypy/testrunner_cfg.py '--config=~/machine_cfg.py' --root=pypy --timeout=4000 in dir /build_dir/own-linux-x86-32/build (timeout 4000 secs) watching logfiles {'pytestLog': 'testrun.log'} argv: ['virt_test/bin/python', 'testrunner/runner.py', '--logfile=testrun.log', '--config=pypy/testrunner_cfg.py', '--config=~/machine_cfg.py', '--root=pypy', '--timeout=4000'] environment: AUDITWHEEL_ARCH=i686 AUDITWHEEL_PLAT=manylinux2014_i686 AUDITWHEEL_POLICY=manylinux2014 DEVTOOLSET_ROOTPATH=/opt/rh/devtoolset-10/root HOME=/home/buildslave HOSTNAME=ffc60fde56a7 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/lib:/opt/rh/devtoolset-10/root/usr/lib/dyninst 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/own-linux-x86-32/build PYPYCHERRYPICK= PYPY_LOCALBASE=/usr/local PYPY_MAKE_PORTABLE=1 PYTHONPATH=.: SHELL=/bin/bash SHLVL=3 SSL_CERT_FILE=/opt/_internal/certs.pem TERM=xterm TMPDIR=/build_dir/tmp/pytest USER=buildslave _=/usr/bin/linux32 using PTY: False using config pypy/testrunner_cfg.py using config /home/buildslave/machine_cfg.py running 4 parallel test workers setting MAKEFLAGS to ' ' (space) -- config/test -- interpreter/astcompiler/test -- interpreter/pyparser/test -- interpreter/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/test_api.py -- module/cpyext/test/test_arraymodule.py -- module/cpyext/test/test_async_iter.py -- module/cpyext/test/test_boolobject.py -- module/cpyext/test/test_borrow.py -- module/cpyext/test/test_buffer.py -- module/cpyext/test/test_bytearrayobject.py -- module/cpyext/test/test_bytesobject.py -- module/cpyext/test/test_capsule.py -- module/cpyext/test/test_cell.py -- module/cpyext/test/test_classobject.py -- module/cpyext/test/test_codecs.py -- module/cpyext/test/test_complexobject.py -- module/cpyext/test/test_contextvars.py -- module/cpyext/test/test_cpyext.py -- module/cpyext/test/test_datetime.py -- module/cpyext/test/test_dictobject.py -- module/cpyext/test/test_eval.py -- module/cpyext/test/test_exception.py -- module/cpyext/test/test_fileobject.py -- module/cpyext/test/test_floatobject.py -- module/cpyext/test/test_frameobject.py -- module/cpyext/test/test_funcobject.py -- module/cpyext/test/test_genobject.py -- module/cpyext/test/test_getargs.py -- module/cpyext/test/test_import.py -- module/cpyext/test/test_iterator.py -- module/cpyext/test/test_listobject.py -- module/cpyext/test/test_longobject.py -- module/cpyext/test/test_mapping.py -- module/cpyext/test/test_marshal.py -- module/cpyext/test/test_memoryobject.py -- module/cpyext/test/test_methodobject.py -- module/cpyext/test/test_misc.py -- module/cpyext/test/test_module.py -- module/cpyext/test/test_namespaceobject.py -- module/cpyext/test/test_ndarrayobject.py -- module/cpyext/test/test_number.py -- module/cpyext/test/test_object.py -- module/cpyext/test/test_pyerrors.py -- module/cpyext/test/test_pyfile.py -- module/cpyext/test/test_pymem.py -- module/cpyext/test/test_pysignals.py -- module/cpyext/test/test_pystate.py -- module/cpyext/test/test_pystrhex.py -- module/cpyext/test/test_pystrtod.py -- module/cpyext/test/test_sequence.py -- module/cpyext/test/test_setobject.py -- module/cpyext/test/test_sliceobject.py -- module/cpyext/test/test_structseq.py -- module/cpyext/test/test_sysmodule.py -- module/cpyext/test/test_thread.py -- module/cpyext/test/test_traceback.py -- module/cpyext/test/test_translate.py -- module/cpyext/test/test_tupleobject.py -- module/cpyext/test/test_typedeallocate.py -- module/cpyext/test/test_typeobject.py -- module/cpyext/test/test_unicodeobject.py -- module/cpyext/test/test_userslots.py -- module/cpyext/test/test_version.py -- module/cpyext/test/test_weakref.py -- 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 -- objspace/fake/test -- objspace/std/test -- objspace/test -- sandbox/test -- tool/bench/test -- tool/memusage/test -- tool/pytest/fake_pytest/test -- tool/pytest/test -- tool/release/test -- tool/test -- total: 144 to run ++ 02:30:31 starting config/test [1 started in total] ++ 02:30:31 starting interpreter/astcompiler/test [2 started in total] ++ 02:30:31 starting interpreter/pyparser/test [3 started in total] ++ 02:30:31 starting interpreter/test [4 started in total] __ config/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 162 items / 1 skipped config/test/test_pypyoption.py .................................................................................................................................................................. ==================== 162 passed, 1 skipped in 9.31 seconds ===================== ++ 02:30:41 starting module/__builtin__/test [5 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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 243 items interpreter/pyparser/test/apptest_parsestring.py ...... interpreter/pyparser/test/test_automata.py ... interpreter/pyparser/test/test_future.py ................................... interpreter/pyparser/test/test_gendfa.py .... interpreter/pyparser/test/test_parsestring.py ............ interpreter/pyparser/test/test_pylexer.py . interpreter/pyparser/test/test_pyparse.py ................................................................................................................. interpreter/pyparser/test/test_pytokenizer.py ..................................................................... ========================= 243 passed in 111.60 seconds ========================= ++ 02:32:27 starting module/__pypy__/test [6 started in total] __ module/__builtin__/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 324 items module/__builtin__/test/apptest_compile.py ..................... module/__builtin__/test/apptest_descriptor.py ....... module/__builtin__/test/apptest_operator.py ..... module/__builtin__/test/apptest_print.py ... module/__builtin__/test/test_abstractinst.py ..........s.. module/__builtin__/test/test_breakpoint.py ........ module/__builtin__/test/test_builtin.py ........................................................................ module/__builtin__/test/test_compile.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 . =================== 323 passed, 1 skipped in 276.96 seconds ==================== ++ 02:35:23 starting module/_abc/test [7 started in total] __ module/_abc/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 6 items module/_abc/test/apptest_abc.py ... module/_abc/test/test_abc.py ... ========================== 6 passed in 102.23 seconds ========================== ++ 02:37:12 starting module/_ast/test [8 started in total] __ module/__pypy__/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 83 items module/__pypy__/test/apptest_picklebuffer.py ........ module/__pypy__/test/test_builders.py ..... module/__pypy__/test/test_bytebuffer.py ... module/__pypy__/test/test_debug.py ....... 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 ..s.s module/__pypy__/test/test_special.py ..........s.s. ==================== 78 passed, 5 skipped in 284.21 seconds ==================== Exception AttributeError: '__exit__' in <bound method Lock.__del__ of <rpython.rlib.rthread.Lock object at 0xf3af46cc>> ignored ++ 02:37:16 starting module/_cffi_backend/test [9 started in total] __ interpreter/astcompiler/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 1566 items interpreter/astcompiler/test/apptest_compiler.py .................... interpreter/astcompiler/test/apptest_exceptiongroup.py ......................... interpreter/astcompiler/test/apptest_fstring.py ............................... interpreter/astcompiler/test/apptest_misc.py ................. interpreter/astcompiler/test/apptest_patma.py ......................................... interpreter/astcompiler/test/apptest_walrus_comprehension.py ...... interpreter/astcompiler/test/test_assemble.py ....................... interpreter/astcompiler/test/test_ast.py ............ interpreter/astcompiler/test/test_astbuilder.py ................................................................................................................. interpreter/astcompiler/test/test_compiler.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... interpreter/astcompiler/test/test_misc.py ............... interpreter/astcompiler/test/test_symtable.py ................................................. interpreter/astcompiler/test/test_unparse.py ................................ interpreter/astcompiler/test/test_validate.py ..................................................... ======================== 1566 passed in 733.26 seconds ========================= ++ 02:42:47 starting module/_codecs/test [10 started in total] __ module/_ast/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 57 items module/_ast/test/apptest_ast.py ... module/_ast/test/test_ast.py ...................................................... ========================= 57 passed in 362.92 seconds ========================== ++ 02:43:21 starting module/_collections/test [11 started in total] __ module/_collections/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 66 items module/_collections/test/apptest_defaultdict.py .............. module/_collections/test/apptest_deque.py .......................................... module/_collections/test/apptest_ordereddict.py .......... ========================= 66 passed in 240.93 seconds ========================== ++ 02:47:26 starting module/_continuation/test [12 started in total] __ module/_codecs/test [9 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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 99 items module/_codecs/test/apptest_codecs.py .. module/_codecs/test/test_codecs.py .....................sss...........................................................s...... module/_codecs/test/test_locale.py ...ss. module/_codecs/test/test_ztranslation.py . ==================== 93 passed, 6 skipped in 425.04 seconds ==================== ++ 02:50:00 starting module/_cppyy/test [13 started in total] __ module/_cppyy/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 0 items ========================= no tests ran in 0.01 seconds ========================= ++ 02:50:05 starting module/_csv/test [14 started in total] __ module/_continuation/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 32 items / 3 skipped module/_continuation/test/test_generator.py .... module/_continuation/test/test_greenlet.py ............................ ==================== 32 passed, 3 skipped in 227.39 seconds ==================== ++ 02:51:18 starting module/_demo/test [15 started in total] __ module/_csv/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 34 items module/_csv/test/apptest_writer.py ...... module/_csv/test/test_dialect.py .............. module/_csv/test/test_reader.py ............. module/_csv/test/test_ztranslation.py . ========================= 34 passed in 162.81 seconds ========================== ++ 02:52:51 starting module/_hpy_universal/test/_vendored [16 started in total] __ module/_demo/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 3 items module/_demo/test/test_import.py .. module/_demo/test/test_sieve.py . ========================== 3 passed in 87.09 seconds =========================== ++ 02:52:52 starting module/_hpy_universal/test/pypy [17 started in total] __ module/_hpy_universal/test/_vendored [14 done in total, somefailed=True] ___ INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/build_dir/own-linux-x86-32/build/_pytest/main.py", line 109, in wrap_session INTERNALERROR> config.hook.pytest_sessionstart(session=session) INTERNALERROR> File "/build_dir/own-linux-x86-32/build/_pytest/vendored_packages/pluggy.py", line 724, in __call__ INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) INTERNALERROR> File "/build_dir/own-linux-x86-32/build/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File "/build_dir/own-linux-x86-32/build/_pytest/vendored_packages/pluggy.py", line 333, in <lambda> INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute() INTERNALERROR> File "/build_dir/own-linux-x86-32/build/_pytest/vendored_packages/pluggy.py", line 596, in execute INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/module/_hpy_universal/test/conftest.py", line 145, in pytest_sessionstart INTERNALERROR> from pypy.module._hpy_universal.test import support as _support INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/module/_hpy_universal/test/support.py", line 6, in <module> INTERNALERROR> from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/module/cpyext/test/test_cpyext.py", line 9, in <module> INTERNALERROR> from pypy.module.cpyext import api INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/module/cpyext/api.py", line 29, in <module> INTERNALERROR> from pypy.interpreter.generator import GeneratorIterator INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/interpreter/generator.py", line 3, in <module> INTERNALERROR> from pypy.interpreter.pyopcode import SApplicationException, Yield INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/interpreter/pyopcode.py", line 15, in <module> INTERNALERROR> from pypy.interpreter import ( INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/interpreter/pyframe.py", line 22, in <module> INTERNALERROR> from pypy.interpreter.pymonitoring import ( INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/interpreter/pymonitoring.py", line 5, in <module> INTERNALERROR> from pypy.interpreter.typedef import TypeDef INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/interpreter/typedef.py", line 572, in <module> INTERNALERROR> from pypy.interpreter.pyframe import PyFrame INTERNALERROR> ImportError: cannot import name PyFrame ++ 02:52:56 starting module/_io/test [18 started in total] __ module/_hpy_universal/test/pypy [15 done in total, somefailed=True] ________ INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/build_dir/own-linux-x86-32/build/_pytest/main.py", line 109, in wrap_session INTERNALERROR> config.hook.pytest_sessionstart(session=session) INTERNALERROR> File "/build_dir/own-linux-x86-32/build/_pytest/vendored_packages/pluggy.py", line 724, in __call__ INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) INTERNALERROR> File "/build_dir/own-linux-x86-32/build/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File "/build_dir/own-linux-x86-32/build/_pytest/vendored_packages/pluggy.py", line 333, in <lambda> INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute() INTERNALERROR> File "/build_dir/own-linux-x86-32/build/_pytest/vendored_packages/pluggy.py", line 596, in execute INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/module/_hpy_universal/test/conftest.py", line 145, in pytest_sessionstart INTERNALERROR> from pypy.module._hpy_universal.test import support as _support INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/module/_hpy_universal/test/support.py", line 6, in <module> INTERNALERROR> from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/module/cpyext/test/test_cpyext.py", line 9, in <module> INTERNALERROR> from pypy.module.cpyext import api INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/module/cpyext/api.py", line 29, in <module> INTERNALERROR> from pypy.interpreter.generator import GeneratorIterator INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/interpreter/generator.py", line 3, in <module> INTERNALERROR> from pypy.interpreter.pyopcode import SApplicationException, Yield INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/interpreter/pyopcode.py", line 15, in <module> INTERNALERROR> from pypy.interpreter import ( INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/interpreter/pyframe.py", line 22, in <module> INTERNALERROR> from pypy.interpreter.pymonitoring import ( INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/interpreter/pymonitoring.py", line 5, in <module> INTERNALERROR> from pypy.interpreter.typedef import TypeDef INTERNALERROR> File "/build_dir/own-linux-x86-32/build/pypy/interpreter/typedef.py", line 572, in <module> INTERNALERROR> from pypy.interpreter.pyframe import PyFrame INTERNALERROR> ImportError: cannot import name PyFrame ++ 02:52:57 starting module/_jitlog/test [19 started in total] __ module/_jitlog/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 1 items module/_jitlog/test/test__jitlog.py . ========================== 1 passed in 46.04 seconds =========================== ++ 02:53:48 starting module/_locale/test [20 started in total] __ module/_locale/test [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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 15 items module/_locale/test/test_locale.py sssssssssssssss ========================= 15 skipped in 35.13 seconds ========================== ++ 02:54:26 starting module/_lsprof/test [21 started in total] __ module/_lsprof/test [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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 6 items module/_lsprof/test/test_cprofile.py ...... ========================== 6 passed in 37.23 seconds =========================== ++ 02:55:10 starting module/_md5/test [22 started in total] __ module/_md5/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 8 items module/_md5/test/test_md5.py ........ ========================== 8 passed in 31.97 seconds =========================== ++ 02:55:48 starting module/_minimal_curses/test [23 started in total] __ module/_minimal_curses/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 6 items module/_minimal_curses/test/test_curses.py ...... ========================== 6 passed in 219.82 seconds ========================== ++ 02:59:32 starting module/_multibytecodec/test [24 started in total] __ module/_multibytecodec/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 67 items module/_multibytecodec/test/apptest_codecs.py ................... module/_multibytecodec/test/apptest_incremental.py .................... module/_multibytecodec/test/apptest_stream.py ..... module/_multibytecodec/test/test_c_codecs.py ..................s module/_multibytecodec/test/test_multibtye_codecs.py ... module/_multibytecodec/test/test_translation.py s ==================== 65 passed, 2 skipped in 165.59 seconds ==================== ++ 03:02:19 starting module/_multiprocessing/test [25 started in total] __ module/_multiprocessing/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 13 items module/_multiprocessing/test/test_interp_semaphore.py . module/_multiprocessing/test/test_semaphore.py .......... module/_multiprocessing/test/test_win32.py s module/_multiprocessing/test/test_ztranslation.py . ==================== 12 passed, 1 skipped in 366.29 seconds ==================== ++ 03:08:27 starting module/_opcode/test [26 started in total] __ module/_opcode/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 5 items module/_opcode/test/apptest_opcode.py ..... ========================== 5 passed in 43.93 seconds =========================== ++ 03:09:18 starting module/_pickle/test [27 started in total] __ interpreter/test [24 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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.py PYTHON3: /usr/local/bin/python3.12 (Version 3.12.7 (main, Oct 26 2024, 09:18:46) [GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]) rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 1389 items interpreter/test/apptest_annotations.py .......................... interpreter/test/apptest_annotations_string.py ...... interpreter/test/apptest_buffer.py ....... interpreter/test/apptest_class.py ................ interpreter/test/apptest_compiler.py ........................F........................................................................... interpreter/test/apptest_coroutine.py .......................................................... interpreter/test/apptest_descrtypecheck.py .. interpreter/test/apptest_exceptions.py .......................... interpreter/test/apptest_exctable_dis.py ......... interpreter/test/apptest_exec.py ......................... interpreter/test/apptest_extcall.py ..... interpreter/test/apptest_function.py .....................................s....................................................... interpreter/test/apptest_generator.py ................................................................... interpreter/test/apptest_nestedscope.py .................. interpreter/test/apptest_pep695.py ............................... interpreter/test/apptest_pycode.py .... interpreter/test/apptest_pyframe.py ................................................................ interpreter/test/apptest_raise.py ...................................................... interpreter/test/apptest_settrace_jump.py . interpreter/test/apptest_syntax.py .................................... interpreter/test/apptest_sys_settrace.py .............................................................................................................................................. interpreter/test/apptest_traceback.py ........ interpreter/test/apptest_unraisable.py .... interpreter/test/apptest_with_leak.py ......... interpreter/test/test_app_main.py ..................s..s....................s...s.......................s....x.s...s.......... interpreter/test/test_appinterp.py ............. interpreter/test/test_argument.py ................................................ interpreter/test/test_buffer.py ... interpreter/test/test_cellfamily.py ....... interpreter/test/test_code.py ............ interpreter/test/test_compiler.py ......... interpreter/test/test_error.py .............. interpreter/test/test_exceptcomp.py ......... interpreter/test/test_executioncontext.py ................ interpreter/test/test_extmodules.py . interpreter/test/test_fsencode.py ... interpreter/test/test_function.py ............. interpreter/test/test_gateway.py .........................................ss......................... interpreter/test/test_generator.py . interpreter/test/test_interpreter.py ................................................. interpreter/test/test_location.py .......... interpreter/test/test_main.py ..... interpreter/test/test_mixedmodule.py ...... interpreter/test/test_module.py .................. interpreter/test/test_monitoring.py ....... interpreter/test/test_objspace.py ............................................. interpreter/test/test_pycode.py .. interpreter/test/test_pyframe.py ................................ interpreter/test/test_reverse_debugging.py .. interpreter/test/test_special.py ... interpreter/test/test_syntax.py ..................... interpreter/test/test_targetpypy.py .. interpreter/test/test_typedef.py ................... interpreter/test/test_unicodehelper.py .......... interpreter/test/test_zpy.py ........ interpreter/test/test_zzpickle_and_slow.py s.....s..s..sss........ss...s. =================================== FAILURES =================================== _______________________ test_dict_and_set_literal_order ________________________ def test_dict_and_set_literal_order(): x = 1 l1 = list({1:'a', 3:'b', 2:'c', 4:'d'}) l2 = list({1, 3, 2, 4}) l3 = list({x:'a', 3:'b', 2:'c', 4:'d'}) l4 = list({x, 3, 2, 4}) if not IS_PYPY: # the full test relies on the host Python providing ordered dicts assert set(l1) == set(l2) == set(l3) == set(l4) == {1, 3, 2, 4} else: > assert l1 == l2 == l3 == l4 == [1, 3, 2, 4] E (application-level) AssertionError: assert [1, 2, 3, 4] == [1, 3, 2, 4] interpreter/test/apptest_compiler.py:228: AssertionError =========================== short test summary info ============================ FAIL interpreter/test/apptest_compiler.py::test_dict_and_set_literal_order ======= 1 failed, 1368 passed, 19 skipped, 1 xfailed in 2454.86 seconds ======== ++ 03:11:34 starting module/_pickle_support/test [28 started in total] __ module/_pickle_support/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 1 items module/_pickle_support/test/apptest__pickle_support.py . ========================== 1 passed in 30.49 seconds =========================== ++ 03:12:06 starting module/_posixsubprocess/test [29 started in total] __ module/_io/test [26 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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 287 items / 1 skipped module/_io/test/apptest_bufferedio.py . module/_io/test/apptest_bytesio.py ................. module/_io/test/apptest_io.py ........................................... module/_io/test/apptest_stringio.py ........................... module/_io/test/apptest_textio.py ..............................s.................F module/_io/test/test_bufferedio.py .......................................................................ss................................ module/_io/test/test_fileio.py .................................... module/_io/test/test_interp_textio.py ......... =================================== FAILURES =================================== _________________________ test_concurrent_next_at_eof __________________________ tempfile = W_UnicodeObject('/build_dir/tmp/pytest/pytest-of-buildslave/pytest-1108/tempfile') def test_concurrent_next_at_eof(tempfile): # https://github.com/pypy/pypy/issues/5575 # Two threads iterating the same TextIOWrapper over a real fd can race # inside the decode buffer when the underlying read() releases the GIL, # especially right at EOF where DecodeBuffer.reset() nulls out its state. import _thread import time with _io.open(tempfile, 'wb') as w: w.write(b"line\n") f = _io.TextIOWrapper(_io.BufferedReader(_io.FileIO(tempfile, "r"))) it = iter(f) done = [] def worker(): for _ in range(10): try: next(it) except Exception: pass done.append(1) _thread.start_new_thread(worker, ()) _thread.start_new_thread(worker, ()) deadline = time.time() + 15.0 while len(done) < 2: > assert time.time() < deadline, "worker threads hung (see issue 5575)" E (application-level) AssertionError: worker threads hung (see issue 5575) E assert 1788318032.0044973 < 1788318031.254039 E + where 1788318032.0044973 = <built-in function time>() E + where <built-in function time> = <module 'time' (built-in)>.time module/_io/test/apptest_textio.py:852: AssertionError =========================== short test summary info ============================ FAIL module/_io/test/apptest_textio.py::test_concurrent_next_at_eof ============== 1 failed, 283 passed, 4 skipped in 1373.07 seconds ============== Exception AttributeError: '__exit__' in <bound method Lock.__del__ of <rpython.rlib.rthread.Lock object at 0xf1d7940c>> ignored ++ 03:15:53 starting module/_pypyjson/test [30 started in total] __ module/_posixsubprocess/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 10 items module/_posixsubprocess/test/apptest_subprocess.py ......... module/_posixsubprocess/test/test_ztranslation.py . ========================= 10 passed in 355.10 seconds ========================== ++ 03:18:07 starting module/_random/test [31 started in total] __ module/_pypyjson/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 54 items / 1 skipped module/_pypyjson/test/apptest__pypyjson.py .......... module/_pypyjson/test/test__pypyjson.py ............................................ ==================== 54 passed, 1 skipped in 196.25 seconds ==================== ++ 03:19:15 starting module/_rawffi/alt/test [32 started in total] __ module/_random/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 13 items module/_random/test/test_random.py ............ module/_random/test/test_ztranslation.py . ========================== 13 passed in 65.80 seconds ========================== ++ 03:19:20 starting module/_rawffi/test [33 started in total] __ module/_rawffi/alt/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 73 items module/_rawffi/alt/test/test_ffitype.py ..... module/_rawffi/alt/test/test_funcptr.py ..................................ssssss.s module/_rawffi/alt/test/test_struct.py ............... module/_rawffi/alt/test/test_type_converter.py ........... ==================== 66 passed, 7 skipped in 67.97 seconds ===================== ++ 03:20:28 starting module/_socket/test [34 started in total] __ module/_pickle/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 108 items module/_pickle/test/apptest_optional_frames.py .. module/_pickle/test/apptest_pickle.py ............................................................................... module/_pickle/test/apptest_pypy_extensions.py ........................... ========================= 108 passed in 805.33 seconds ========================= ++ 03:22:46 starting module/_sre/test [35 started in total] __ module/_rawffi/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 86 items module/_rawffi/test/apptest_rawffi.py .. module/_rawffi/test/test__rawffi.py ......s.............................................s..........s...n: 2 Arg 0: 3 Arg 1: 15 ... module/_rawffi/test/test_exit.py . module/_rawffi/test/test_nested.py ...... module/_rawffi/test/test_struct.py ... module/_rawffi/test/test_tracker.py ... module/_rawffi/test/test_ztranslation.py . ==================== 83 passed, 3 skipped in 270.37 seconds ==================== Exception AttributeError: '__exit__' in <bound method Lock.__del__ of <rpython.rlib.rthread.Lock object at 0xf3a2b60c>> ignored ++ 03:23:55 starting module/_vmprof/test [36 started in total] __ module/_vmprof/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 7 items module/_vmprof/test/test__vmprof.py ..... module/_vmprof/test/test_direct.py .. ========================== 7 passed in 161.60 seconds ========================== ++ 03:26:41 starting module/_warnings/test [37 started in total] __ module/_warnings/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 22 items module/_warnings/test/apptest_warnings.py ........s.s.......... module/_warnings/test/test_warnings.py . ==================== 20 passed, 2 skipped in 110.78 seconds ==================== ++ 03:28:37 starting module/_weakref/test [38 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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 87 items module/_socket/test/apptest_socket.py .....................ss..................s................s... module/_socket/test/test_sock_app.py .................ss..... module/_socket/test/test_ztranslation.py . ==================== 81 passed, 6 skipped in 508.71 seconds ==================== ++ 03:29:00 starting module/_winreg/test [39 started in total] __ module/_winreg/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 0 items / 1 skipped ========================== 1 skipped in 0.08 seconds =========================== ++ 03:29:01 starting module/array/test [40 started in total] __ module/_sre/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 163 items module/_sre/test/apptest_sre.py ................................................................................s.s...................... module/_sre/test/test_app_sre.py .............................. module/_sre/test/test_sre_buf.py ............................ =================== 161 passed, 2 skipped in 539.03 seconds ==================== ++ 03:31:47 starting module/atexit/test [41 started in total] __ module/_weakref/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 43 items module/_weakref/test/apptest_weakref.py ........................................... ========================= 43 passed in 247.81 seconds ========================== ++ 03:32:50 starting module/binascii/test [42 started in total] __ module/atexit/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 2 items module/atexit/test/apptest_atexit.py .. ========================== 2 passed in 60.69 seconds =========================== ++ 03:32:53 starting module/bz2/test [43 started in total] __ module/binascii/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 18 items module/binascii/test/test_binascii.py .................. ========================== 18 passed in 68.39 seconds ========================== ++ 03:34:03 starting module/cmath/test [44 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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 64 items module/array/test/apptest_array.py ... module/array/test/test_array.py .....................s..................s................... module/array/test/test_ztranslation.py . ==================== 62 passed, 2 skipped in 331.05 seconds ==================== ++ 03:34:41 starting module/cpyext/test/test_api.py [45 started in total] __ module/cmath/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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 18 items module/cmath/test/test_cmath.py .................. ========================== 18 passed in 34.51 seconds ========================== ++ 03:34:41 starting module/cpyext/test/test_arraymodule.py [46 started in total] __ module/_cffi_backend/test [43 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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 468 items module/_cffi_backend/test/test_c.py ....................................................................................s....................................................s.....s.......................s.............................s........................s...... module/_cffi_backend/test/test_fastpath.py .................. module/_cffi_backend/test/test_ffi_obj.py ............................................... module/_cffi_backend/test/test_file.py s.. module/_cffi_backend/test/test_parse_c_type.py ..............s... module/_cffi_backend/test/test_re_python.py .................... module/_cffi_backend/test/test_recompiler.py EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE module/_cffi_backend/test/test_unicode_literals.py ....... module/_cffi_backend/test/test_wchar_helper.py . module/_cffi_backend/test/test_ztranslation.py s ==================================== ERRORS ==================================== ______________ ERROR at setup of AppTestRecompiler.test_math_sin _______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3a9ef7c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_math_sin'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_math_sin'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_math_sin'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_math_sin'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_math_sin'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_math_sin'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_math_sin'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf02513c4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_math_sin'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf02a9d2c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf02a9d2c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_math_sin'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_math_sin'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_math_sin'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xf02a9e6c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf02a9e6c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf02a9e6c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xf02a9e6c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf00ae3ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeffa7cec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeffa7d4c>, <W_TypeObject 'MemoryError' at 0xf02247cc>, <W_TypeObject 'bytearray' at 0xf...or' at 0xf023248c>, <W_TypeObject 'cinstancemethod' at 0xeffb31cc>, <W_TypeObject 'AttributeError' at 0xf0237fec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefdb584c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefdb584c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefdb584c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefdb584c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb901570>> w_obj = <W_TypeObject 'ellipsis' at 0xefdb584c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xefdb584c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb901570>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xefdb584c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb901570>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb901570>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb901570>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_repr_lib _______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf2ffd87c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_repr_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_lib'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_repr_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_lib'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_repr_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_lib'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_repr_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xefda85a4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_repr_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefba526c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefba526c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_repr_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_repr_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_lib'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefba520c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefba520c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefba520c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefba520c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xefba190c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefa62e2c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xefa62e8c>, <W_TypeObject 'MemoryError' at 0xefb1cdac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xefbace4c>, <W_TypeObject 'cinstancemethod' at 0xefc0e2ec>, <W_TypeObject 'AttributeError' at 0xefb889cc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef79934c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef79934c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef79934c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef79934c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb73d838>> w_obj = <W_TypeObject 'ellipsis' at 0xef79934c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef79934c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb73d838>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef79934c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb73d838>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb73d838>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb73d838>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____________ ERROR at setup of AppTestRecompiler.test_funcarg_ptr _____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf0cdf294>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_funcarg_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_funcarg_ptr'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_funcarg_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_funcarg_ptr'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_funcarg_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_funcarg_ptr'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_funcarg_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xefbe40a4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...uncarg_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefbe11cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefbe11cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...uncarg_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_funcarg_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_funcarg_ptr'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefbe132c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefbe132c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefbe132c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefbe132c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef5abc6c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefb30fac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xefb300ac>, <W_TypeObject 'MemoryError' at 0xef59fbac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef59948c>, <W_TypeObject 'cinstancemethod' at 0xefb3072c>, <W_TypeObject 'AttributeError' at 0xef5b0dec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb0584c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb0584c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb0584c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb0584c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbba35e0>> w_obj = <W_TypeObject 'ellipsis' at 0xefb0584c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xefb0584c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbba35e0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xefb0584c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbba35e0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbba35e0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbba35e0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____________ ERROR at setup of AppTestRecompiler.test_funcres_ptr _____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1e84064>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_funcres_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_funcres_ptr'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_funcres_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_funcres_ptr'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_funcres_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_funcres_ptr'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_funcres_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef7813ec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...uncres_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef6e9b2c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef6e9b2c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...uncres_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_funcres_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_funcres_ptr'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef6e934c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef6e934c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef6e934c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef6e934c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef65206c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef6e29cc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef6e2b2c>, <W_TypeObject 'MemoryError' at 0xef8ea52c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef8bfb6c>, <W_TypeObject 'cinstancemethod' at 0xef97794c>, <W_TypeObject 'AttributeError' at 0xef8cec8c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef4055cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef4055cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef4055cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef4055cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc244410>> w_obj = <W_TypeObject 'ellipsis' at 0xef4055cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef4055cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc244410>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef4055cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc244410>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc244410>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc244410>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __________ ERROR at setup of AppTestRecompiler.test_global_var_array ___________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1e75c6c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_global_var_array'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_global_var_array'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_global_var_array'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xefc13c84> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef96f04c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef96f04c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_global_var_array'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef96f40c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef96f40c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef96f40c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef96f40c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef6da44c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef9664ec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef9661ec>, <W_TypeObject 'MemoryError' at 0xef8c9b6c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef39324c>, <W_TypeObject 'cinstancemethod' at 0xef96680c>, <W_TypeObject 'AttributeError' at 0xef6fb4ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb7954c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb7954c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb7954c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb7954c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa51b3d8>> w_obj = <W_TypeObject 'ellipsis' at 0xefb7954c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xefb7954c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa51b3d8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xefb7954c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa51b3d8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa51b3d8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa51b3d8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_verify_typedef ____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1e7c1ec>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_typedef'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_typedef'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_typedef'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xefa88e14> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...fy_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef94978c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef94978c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...fy_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_typedef'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef949d0c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef949d0c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef949d0c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef949d0c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef925d6c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef418dcc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef418cec>, <W_TypeObject 'MemoryError' at 0xef5d07ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef39e38c>, <W_TypeObject 'cinstancemethod' at 0xef42786c>, <W_TypeObject 'AttributeError' at 0xef3a3e6c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2e1d6c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2e1d6c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2e1d6c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2e1d6c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbb9f060>> w_obj = <W_TypeObject 'ellipsis' at 0xef2e1d6c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef2e1d6c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbb9f060>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef2e1d6c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbb9f060>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbb9f060>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbb9f060>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_verify_typedef_dotdotdot _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf2b00294>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_typedef_dotdotdot'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_typedef_dotdotdot'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_typedef_dotdotdot'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf0629644> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefabb4ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefabb4ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_typedef_dotdotdot'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefabbc0c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefabbc0c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefabbc0c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefabbc0c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef4662ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefaa490c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xefaa492c>, <W_TypeObject 'MemoryError' at 0xef9355ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef3d6d2c>, <W_TypeObject 'cinstancemethod' at 0xefaaf30c>, <W_TypeObject 'AttributeError' at 0xefbc026c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9b1e8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9b1e8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9b1e8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9b1e8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd10628>> w_obj = <W_TypeObject 'ellipsis' at 0xef9b1e8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef9b1e8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd10628>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef9b1e8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd10628>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd10628>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd10628>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____ ERROR at setup of AppTestRecompiler.test_verify_typedef_star_dotdotdot ____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3bb21ec>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef_star_dotdotdot'>...call__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_typedef_star_dotdotdot'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef_star_dotdotdot'>...call__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_typedef_star_dotdotdot'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef_star_dotdotdot'>...call__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_typedef_star_dotdotdot'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef_star_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef8fd34c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef2c432c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef2c432c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_typedef_star_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_typedef_star_dotdotdot'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef2c44cc> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef2c44cc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef2c44cc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef2c44cc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef6e516c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef59fcac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef59f94c>, <W_TypeObject 'MemoryError' at 0xef5a6acc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef34a64c>, <W_TypeObject 'cinstancemethod' at 0xef59ff0c>, <W_TypeObject 'AttributeError' at 0xefbcceac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef54c12c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef54c12c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef54c12c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef54c12c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6b42a0>> w_obj = <W_TypeObject 'ellipsis' at 0xef54c12c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef54c12c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6b42a0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef54c12c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6b42a0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6b42a0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6b42a0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_global_var_int ____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1e6bbfc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_int'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_global_var_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_int'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_global_var_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_int'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_global_var_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, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_int'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xefbd7eb4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...al_var_int'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef84d34c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef84d34c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...al_var_int'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_int'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_global_var_int'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef84d02c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef84d02c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef84d02c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef84d02c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef5225cc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefa9ae8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xefa9a6ac>, <W_TypeObject 'MemoryError' at 0xef34a84c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xefa8d88c>, <W_TypeObject 'cinstancemethod' at 0xefb0598c>, <W_TypeObject 'AttributeError' at 0xef70796c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefbb274c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefbb274c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefbb274c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefbb274c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd25400>> w_obj = <W_TypeObject 'ellipsis' at 0xefbb274c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xefbb274c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd25400>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xefbb274c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd25400>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd25400>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd25400>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________________ ERROR at setup of AppTestRecompiler.test_macro ________________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3548c6c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_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, 5 meths, kwargs={'item': <AppTestMethod 'test_macro'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef9fde14> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...test_macro'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef407c0c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef407c0c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...test_macro'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef40784c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef40784c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef40784c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef40784c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf4e7634c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef9c98cc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef9c91ec>, <W_TypeObject 'MemoryError' at 0xef9352ac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef6da1ec>, <W_TypeObject 'cinstancemethod' at 0xef9c91cc>, <W_TypeObject 'AttributeError' at 0xef96ac8c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef84e14c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef84e14c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef84e14c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef84e14c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa527c60>> w_obj = <W_TypeObject 'ellipsis' at 0xef84e14c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef84e14c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa527c60>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef84e14c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa527c60>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa527c60>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa527c60>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __________ ERROR at setup of AppTestRecompiler.test_macro_check_value __________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf28d780c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro_check_value'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macro_check_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro_check_value'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macro_check_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro_check_value'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macro_check_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, 5 meths, kwargs={'item': <AppTestMethod 'test_macro_check_value'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef976b1c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...heck_value'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef5ab94c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef5ab94c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...heck_value'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro_check_value'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_check_value'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef5ab20c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef5ab20c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef5ab20c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef5ab20c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef680aec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef960e8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef9609ac>, <W_TypeObject 'MemoryError' at 0xef9cd4cc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef1283cc>, <W_TypeObject 'cinstancemethod' at 0xef9600ec>, <W_TypeObject 'AttributeError' at 0xef13352c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2787cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2787cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2787cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2787cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc77d788>> w_obj = <W_TypeObject 'ellipsis' at 0xef2787cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef2787cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc77d788>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef2787cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc77d788>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc77d788>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc77d788>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_constant _______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf21dea3c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef5ee8ec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefb2064c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefb2064c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_constant'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef67b04c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef67b04c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef67b04c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef67b04c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef9492cc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefa8ddec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xefa8d10c>, <W_TypeObject 'MemoryError' at 0xef87228c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef87bb0c>, <W_TypeObject 'cinstancemethod' at 0xefa8324c>, <W_TypeObject 'AttributeError' at 0xef179dac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef96f38c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef96f38c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef96f38c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef96f38c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb91bbf8>> w_obj = <W_TypeObject 'ellipsis' at 0xef96f38c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef96f38c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb91bbf8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef96f38c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb91bbf8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb91bbf8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb91bbf8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_check_value_of_static_const _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf28f93ac>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_check_value_of_static_const'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_check_value_of_static_const'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_check_value_of_static_const'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_check_value_of_static_const'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_check_value_of_static_const'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_check_value_of_static_const'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_check_value_of_static_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef8c6374> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...atic_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef2e192c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef2e192c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...atic_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_check_value_of_static_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_value_of_static_const'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef2e1fec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef2e1fec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef2e1fec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef2e1fec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef59662c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef9ef8cc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef9ef80c>, <W_TypeObject 'MemoryError' at 0xef595f0c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef3ebdec>, <W_TypeObject 'cinstancemethod' at 0xef9ef46c>, <W_TypeObject 'AttributeError' at 0xefb3084c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef611e8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef611e8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef611e8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef611e8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbfbfbc0>> w_obj = <W_TypeObject 'ellipsis' at 0xef611e8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef611e8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbfbfbc0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef611e8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbfbfbc0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbfbfbc0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbfbfbc0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_constant_nonint ___________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf2e803e4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_nonint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_nonint'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_nonint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_nonint'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_nonint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_nonint'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_nonint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef695b94> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ant_nonint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf03466ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf03466ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ant_nonint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_nonint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_constant_nonint'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefa1146c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefa1146c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefa1146c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefa1146c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef51d14c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef9e672c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef9e64ac>, <W_TypeObject 'MemoryError' at 0xef6e526c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef9c978c>, <W_TypeObject 'cinstancemethod' at 0xef2d218c>, <W_TypeObject 'AttributeError' at 0xef4271ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef5cacec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef5cacec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef5cacec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef5cacec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc250948>> w_obj = <W_TypeObject 'ellipsis' at 0xef5cacec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef5cacec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc250948>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef5cacec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc250948>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc250948>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc250948>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____________ ERROR at setup of AppTestRecompiler.test_constant_ptr _____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf18e7e2c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_ptr'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_ptr'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_ptr'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xefbc952c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nstant_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefa82d4c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefa82d4c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nstant_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_ptr'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_constant_ptr'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefa8262c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefa8262c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefa8262c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefa8262c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef40512c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef55648c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef55616c>, <W_TypeObject 'MemoryError' at 0xef79d80c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xefa8df8c>, <W_TypeObject 'cinstancemethod' at 0xefa9f06c>, <W_TypeObject 'AttributeError' at 0xefb01c8c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef76834c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef76834c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef76834c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef76834c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc60e008>> w_obj = <W_TypeObject 'ellipsis' at 0xef76834c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef76834c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc60e008>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef76834c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc60e008>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc60e008>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc60e008>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________________ ERROR at setup of AppTestRecompiler.test_dir _________________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf305f09c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dir'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dir'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dir'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dir'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dir'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dir'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dir'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef44e16c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i... 'test_dir'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef71f9ec> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef71f9ec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i... 'test_dir'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dir'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_dir'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef71fcac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef71fcac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef71fcac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef71fcac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef128ccc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef16bf2c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef16ba0c>, <W_TypeObject 'MemoryError' at 0xef15572c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef14e2ac>, <W_TypeObject 'cinstancemethod' at 0xef16b68c>, <W_TypeObject 'AttributeError' at 0xef51de4c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefa6620c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefa6620c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefa6620c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefa6620c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc784ce0>> w_obj = <W_TypeObject 'ellipsis' at 0xefa6620c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xefa6620c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc784ce0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xefa6620c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc784ce0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc784ce0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc784ce0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_verify_opaque_struct _________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3060e2c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_opaque_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_opaque_struct'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_opaque_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_opaque_struct'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_opaque_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_opaque_struct'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_opaque_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeffac284> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...que_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef5422ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef5422ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...que_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_opaque_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_opaque_struct'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef542f8c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef542f8c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef542f8c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef542f8c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef41c22c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefa6612c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef5e768c>, <W_TypeObject 'MemoryError' at 0xef97502c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef82a7ec>, <W_TypeObject 'cinstancemethod' at 0xef80374c>, <W_TypeObject 'AttributeError' at 0xefa8d04c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8635ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8635ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8635ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8635ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa44e6e8>> w_obj = <W_TypeObject 'ellipsis' at 0xef8635ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef8635ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa44e6e8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef8635ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa44e6e8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa44e6e8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa44e6e8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_verify_opaque_union _________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3a9ce2c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_opaque_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_opaque_union'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_opaque_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_opaque_union'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_opaque_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_opaque_union'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_opaque_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xefb47554> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...aque_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefb79cec> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefb79cec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...aque_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_opaque_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_opaque_union'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefb796cc> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefb796cc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefb796cc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefb796cc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef9408ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef5348cc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef534e6c>, <W_TypeObject 'MemoryError' at 0xef9ef4ac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef7d35ac>, <W_TypeObject 'cinstancemethod' at 0xef534f6c>, <W_TypeObject 'AttributeError' at 0xef85ea6c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef0dffac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef0dffac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef0dffac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef0dffac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbfd0100>> w_obj = <W_TypeObject 'ellipsis' at 0xef0dffac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef0dffac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbfd0100>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef0dffac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbfd0100>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbfd0100>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbfd0100>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____________ ERROR at setup of AppTestRecompiler.test_verify_struct ____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3b7941c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_struct'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_struct'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_struct'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef42911c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ify_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef11652c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef11652c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ify_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_struct'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef11674c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef11674c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef11674c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef11674c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef280ccc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeefae1ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeefaef6c>, <W_TypeObject 'MemoryError' at 0xef55cd2c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef2acdac>, <W_TypeObject 'cinstancemethod' at 0xef4e90ac>, <W_TypeObject 'AttributeError' at 0xefb15a8c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef628e8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef628e8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef628e8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef628e8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc402ef0>> w_obj = <W_TypeObject 'ellipsis' at 0xef628e8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef628e8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc402ef0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef628e8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc402ef0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc402ef0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc402ef0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_verify_exact_field_offset ______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf32ce614>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_exact_field_offset'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_exact_field_offset'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_exact_field_offset'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_exact_field_offset'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_exact_field_offset'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_exact_field_offset'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_exact_field_offset'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef24aaa4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...eld_offset'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef9ef36c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef9ef36c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...eld_offset'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_exact_field_offset'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_exact_field_offset'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef9ef5ac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef9ef5ac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef9ef5ac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef9ef5ac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xefa9ffec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef6a6ecc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef6a67ac>, <W_TypeObject 'MemoryError' at 0xef13436c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef803ccc>, <W_TypeObject 'cinstancemethod' at 0xef8a266c>, <W_TypeObject 'AttributeError' at 0xef35a7cc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9cd8cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9cd8cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9cd8cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9cd8cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3cde28>> w_obj = <W_TypeObject 'ellipsis' at 0xef9cd8cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef9cd8cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3cde28>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef9cd8cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3cde28>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3cde28>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3cde28>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____________ ERROR at setup of AppTestRecompiler.test_type_caching _____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf254cae4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_type_caching'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_type_caching'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_type_caching'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_type_caching'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_type_caching'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_type_caching'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_type_caching'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef8fb0a4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...pe_caching'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef7d64c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef7d64c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...pe_caching'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_type_caching'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_type_caching'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeef7d7ec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef7d7ec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef7d7ec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeef7d7ec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef4b3acc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef4e778c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef4e7dec>, <W_TypeObject 'MemoryError' at 0xeef92aec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeef3162c>, <W_TypeObject 'cinstancemethod' at 0xef4c05ac>, <W_TypeObject 'AttributeError' at 0xeef8ba4c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef70d78c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef70d78c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef70d78c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef70d78c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb751028>> w_obj = <W_TypeObject 'ellipsis' at 0xef70d78c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef70d78c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb751028>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef70d78c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb751028>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb751028>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb751028>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____________ ERROR at setup of AppTestRecompiler.test_verify_enum _____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1e99844>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_enum'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_enum'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_enum'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_enum'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_enum'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_enum'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_enum'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef44e16c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...erify_enum'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef8c9a6c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef8c9a6c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...erify_enum'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_enum'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_enum'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef8c9e0c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef8c9e0c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef8c9e0c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef8c9e0c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef629d2c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef2ddbac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef2dd54c>, <W_TypeObject 'MemoryError' at 0xef7afe6c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xefc3424c>, <W_TypeObject 'cinstancemethod' at 0xef534d0c>, <W_TypeObject 'AttributeError' at 0xef822a0c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef31b5cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef31b5cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef31b5cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef31b5cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa521e08>> w_obj = <W_TypeObject 'ellipsis' at 0xef31b5cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef31b5cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa521e08>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef31b5cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa521e08>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa521e08>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa521e08>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___ ERROR at setup of AppTestRecompiler.test_dotdotdot_length_of_array_field ___ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf2533b54>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dotdotdot_length_of_array_field...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dotdotdot_length_of_array_field'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dotdotdot_length_of_array_field...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dotdotdot_length_of_array_field'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dotdotdot_length_of_array_field...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dotdotdot_length_of_array_field'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dotdotdot_length_of_array_field'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xefa34784> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...rray_field'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef34f52c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef34f52c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...rray_field'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dotdotdot_length_of_array_field'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_dotdotdot_length_of_array_field'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef34fb4c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef34fb4c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef34fb4c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef34fb4c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef91580c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef966dac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef9664cc>, <W_TypeObject 'MemoryError' at 0xef559acc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef9609ec>, <W_TypeObject 'cinstancemethod' at 0xef30090c>, <W_TypeObject 'AttributeError' at 0xef3666cc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeed596c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeed596c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeed596c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeed596c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc20bdb8>> w_obj = <W_TypeObject 'ellipsis' at 0xeeed596c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeeed596c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc20bdb8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeeed596c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc20bdb8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc20bdb8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc20bdb8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _______ ERROR at setup of AppTestRecompiler.test_dotdotdot_global_array ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf33545dc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dotdotdot_global_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dotdotdot_global_array'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dotdotdot_global_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dotdotdot_global_array'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dotdotdot_global_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dotdotdot_global_array'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dotdotdot_global_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef2ef7fc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...obal_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef925c8c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef925c8c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...obal_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_dotdotdot_global_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_dotdotdot_global_array'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef92504c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef92504c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef92504c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef92504c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef3f624c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef5ec44c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef5ec34c>, <W_TypeObject 'MemoryError' at 0xeee3dd6c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef2e152c>, <W_TypeObject 'cinstancemethod' at 0xef5ec90c>, <W_TypeObject 'AttributeError' at 0xef10c56c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef608cec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef608cec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef608cec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef608cec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa472c90>> w_obj = <W_TypeObject 'ellipsis' at 0xef608cec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef608cec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa472c90>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef608cec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa472c90>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa472c90>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa472c90>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_misdeclared_field_1 _________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf12b1374>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_misdeclared_field_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_misdeclared_field_1'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_misdeclared_field_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_misdeclared_field_1'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_misdeclared_field_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_misdeclared_field_1'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_misdeclared_field_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef7c4b44> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ed_field_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeefc1f2c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeefc1f2c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ed_field_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_misdeclared_field_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_misdeclared_field_1'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeefc1b0c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeefc1b0c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeefc1b0c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeefc1b0c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xefaa464c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeeff3e8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeeff316c>, <W_TypeObject 'MemoryError' at 0xef8c9dac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef369a6c>, <W_TypeObject 'cinstancemethod' at 0xef4b3c6c>, <W_TypeObject 'AttributeError' at 0xef2f878c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef750e4c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef750e4c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef750e4c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef750e4c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc23a590>> w_obj = <W_TypeObject 'ellipsis' at 0xef750e4c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef750e4c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc23a590>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef750e4c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc23a590>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc23a590>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc23a590>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_open_array_in_struct _________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf261d95c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_open_array_in_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_open_array_in_struct'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_open_array_in_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_open_array_in_struct'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_open_array_in_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_open_array_in_struct'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_open_array_in_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef6c5784> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._in_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef33ba4c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef33ba4c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._in_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_open_array_in_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_open_array_in_struct'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef33b06c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef33b06c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef33b06c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef33b06c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef2b5fec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeeecdfac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeeecd2ac>, <W_TypeObject 'MemoryError' at 0xeefa75ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef8bcb8c>, <W_TypeObject 'cinstancemethod' at 0xeeecd88c>, <W_TypeObject 'AttributeError' at 0xef3daeec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefccd2c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefccd2c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefccd2c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefccd2c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5df370>> w_obj = <W_TypeObject 'ellipsis' at 0xeefccd2c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeefccd2c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5df370>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeefccd2c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5df370>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5df370>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5df370>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____________ ERROR at setup of AppTestRecompiler.test_math_sin_type ____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf12a20d4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_math_sin_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_math_sin_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_math_sin_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_math_sin_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_math_sin_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_math_sin_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, 5 meths, kwargs={'item': <AppTestMethod 'test_math_sin_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef4ffe3c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...h_sin_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef58d10c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef58d10c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...h_sin_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_math_sin_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_math_sin_type'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef58d3cc> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef58d3cc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef58d3cc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef58d3cc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef293c2c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefb6c3ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xefb6c0ac>, <W_TypeObject 'MemoryError' at 0xeed8836c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef62aecc>, <W_TypeObject 'cinstancemethod' at 0xef27f72c>, <W_TypeObject 'AttributeError' at 0xef85e3ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef59fe0c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef59fe0c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef59fe0c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef59fe0c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd223a0>> w_obj = <W_TypeObject 'ellipsis' at 0xef59fe0c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef59fe0c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd223a0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef59fe0c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd223a0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd223a0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd223a0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ERROR at setup of AppTestRecompiler.test_verify_anonymous_struct_with_typedef _ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf252f5a4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_struct_with_ty...: <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_anonymous_struct_with_typedef'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_struct_with_ty...: <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_anonymous_struct_with_typedef'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_struct_with_ty...: <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_anonymous_struct_with_typedef'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_struct_with_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef76f0cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...th_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef466a2c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef466a2c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...th_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_struct_with_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_anonymous_struct_with_typedef'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef466aec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef466aec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef466aec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef466aec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeee8e74c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeefbcdac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeefbca2c>, <W_TypeObject 'MemoryError' at 0xef06884c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef1f8f6c>, <W_TypeObject 'cinstancemethod' at 0xef4e036c>, <W_TypeObject 'AttributeError' at 0xef1e528c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeed8a4cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeed8a4cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeed8a4cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeed8a4cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa5372f8>> w_obj = <W_TypeObject 'ellipsis' at 0xeed8a4cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeed8a4cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa5372f8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeed8a4cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa5372f8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa5372f8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa5372f8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ERROR at setup of AppTestRecompiler.test_verify_anonymous_struct_with_star_typedef self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf129d8b4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_struct_with_st...ultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_anonymous_struct_with_star_typedef'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_struct_with_st...ultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_anonymous_struct_with_star_typedef'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_struct_with_st...ultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_anonymous_struct_with_star_typedef'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_struct_with_star_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef5eeb1c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ar_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef769f4c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef769f4c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ar_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_struct_with_star_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_anonymous_struct_with_star_typedef'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef769dec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef769dec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef769dec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef769dec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef0a8a0c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef24d60c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef24db2c>, <W_TypeObject 'MemoryError' at 0xefc1606c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef5710ac>, <W_TypeObject 'cinstancemethod' at 0xef7bd16c>, <W_TypeObject 'AttributeError' at 0xef1ef6ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefba6bac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefba6bac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefba6bac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefba6bac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbbe82f0>> w_obj = <W_TypeObject 'ellipsis' at 0xefba6bac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xefba6bac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbbe82f0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xefba6bac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbbe82f0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbbe82f0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbbe82f0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _ ERROR at setup of AppTestRecompiler.test_verify_anonymous_enum_with_typedef __ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf109ef7c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_enum_with_type..._': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_anonymous_enum_with_typedef'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_enum_with_type..._': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_anonymous_enum_with_typedef'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_enum_with_type..._': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_verify_anonymous_enum_with_typedef'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_enum_with_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef7c4af4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...th_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefbc01ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefbc01ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...th_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_verify_anonymous_enum_with_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_verify_anonymous_enum_with_typedef'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefbc030c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefbc030c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefbc030c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefbc030c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeef2fe0c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef4c1c8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef4c13cc>, <W_TypeObject 'MemoryError' at 0xef58ffac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeef313ec>, <W_TypeObject 'cinstancemethod' at 0xef6e80ec>, <W_TypeObject 'AttributeError' at 0xeed4fd6c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8010cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8010cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8010cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8010cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb9df810>> w_obj = <W_TypeObject 'ellipsis' at 0xef8010cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef8010cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb9df810>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef8010cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb9df810>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb9df810>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb9df810>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____________ ERROR at setup of AppTestRecompiler.test_unique_types _____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1d82dbc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unique_types'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unique_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unique_types'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unique_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unique_types'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unique_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, 5 meths, kwargs={'item': <AppTestMethod 'test_unique_types'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef8ba98c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ique_types'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef1e542c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef1e542c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ique_types'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unique_types'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_unique_types'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef1e586c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef1e586c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef1e586c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef1e586c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef35936c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef28ceec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef108b2c>, <W_TypeObject 'MemoryError' at 0xef06884c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeeec0a8c>, <W_TypeObject 'cinstancemethod' at 0xef466bec>, <W_TypeObject 'AttributeError' at 0xef2e186c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef268e8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef268e8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef268e8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef268e8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6fbd18>> w_obj = <W_TypeObject 'ellipsis' at 0xef268e8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef268e8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6fbd18>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef268e8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6fbd18>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6fbd18>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6fbd18>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _______ ERROR at setup of AppTestRecompiler.test_module_name_in_package ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf20b156c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_module_name_in_package'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_module_name_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_module_name_in_package'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_module_name_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_module_name_in_package'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_module_name_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, 5 meths, kwargs={'item': <AppTestMethod 'test_module_name_in_package'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef4a18c4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...in_package'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef49660c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef49660c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...in_package'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_module_name_in_package'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_in_package'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef496f4c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef496f4c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef496f4c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef496f4c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef4afaac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefaddaac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xefadd3ec>, <W_TypeObject 'MemoryError' at 0xef9159ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef1415cc>, <W_TypeObject 'cinstancemethod' at 0xefaddf8c>, <W_TypeObject 'AttributeError' at 0xefb4b22c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef595bec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef595bec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef595bec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef595bec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc891e08>> w_obj = <W_TypeObject 'ellipsis' at 0xef595bec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef595bec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc891e08>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef595bec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc891e08>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc891e08>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc891e08>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____ ERROR at setup of AppTestRecompiler.test_unspecified_size_of_global_1 _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf13fd33c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_1'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_1'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_1'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_1'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_1'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_1'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef1fb93c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_global_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef08f6c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef08f6c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_global_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_unspecified_size_of_global_1'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeef0816c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef0816c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef0816c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeef0816c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef28a3ec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeed9f2ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeed9fb2c>, <W_TypeObject 'MemoryError' at 0xeeec0ccc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xefae84cc>, <W_TypeObject 'cinstancemethod' at 0xeefde0ac>, <W_TypeObject 'AttributeError' at 0xef1764ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1cb1ec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1cb1ec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1cb1ec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1cb1ec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa495ed0>> w_obj = <W_TypeObject 'ellipsis' at 0xef1cb1ec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef1cb1ec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa495ed0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef1cb1ec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa495ed0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa495ed0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa495ed0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____ ERROR at setup of AppTestRecompiler.test_unspecified_size_of_global_2 _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf18c409c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_2'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_2'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_2'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_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, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef7c7e3c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_global_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef57d3ec> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef57d3ec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_global_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_unspecified_size_of_global_2'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef57d7ac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef57d7ac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef57d7ac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef57d7ac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xefb0994c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefa705ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef777cec>, <W_TypeObject 'MemoryError' at 0xef9666cc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeeb8806c>, <W_TypeObject 'cinstancemethod' at 0xef7778ec>, <W_TypeObject 'AttributeError' at 0xef2932ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb9dc8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb9dc8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb9dc8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb9dc8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6ad300>> w_obj = <W_TypeObject 'ellipsis' at 0xeeb9dc8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeeb9dc8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6ad300>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeeb9dc8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6ad300>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6ad300>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6ad300>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____ ERROR at setup of AppTestRecompiler.test_unspecified_size_of_global_3 _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf18b8c6c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_3'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_3'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_3'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_3'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_3'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_3'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef29970c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_global_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef4fa9cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef4fa9cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_global_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_unspecified_size_of_global_3'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef4fa9ac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef4fa9ac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef4fa9ac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef4fa9ac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef1078ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef068e4c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef06802c>, <W_TypeObject 'MemoryError' at 0xefaf56cc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef31384c>, <W_TypeObject 'cinstancemethod' at 0xef06864c>, <W_TypeObject 'AttributeError' at 0xef4b39ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9527ec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9527ec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9527ec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9527ec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb766340>> w_obj = <W_TypeObject 'ellipsis' at 0xef9527ec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef9527ec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb766340>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef9527ec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb766340>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb766340>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb766340>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____ ERROR at setup of AppTestRecompiler.test_unspecified_size_of_global_4 _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1a21bfc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_4'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_4'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_4'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_4'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_4'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unspecified_size_of_global_4'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef9f5be4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_global_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefaa472c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefaa472c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_global_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unspecified_size_of_global_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_unspecified_size_of_global_4'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefaa4ccc> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefaa4ccc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefaa4ccc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefaa4ccc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef8035cc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef54ef2c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef54e66c>, <W_TypeObject 'MemoryError' at 0xef620a8c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeee2772c>, <W_TypeObject 'cinstancemethod' at 0xeeea140c>, <W_TypeObject 'AttributeError' at 0xef62924c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1cbcac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1cbcac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1cbcac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1cbcac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa51b870>> w_obj = <W_TypeObject 'ellipsis' at 0xef1cbcac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef1cbcac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa51b870>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef1cbcac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa51b870>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa51b870>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa51b870>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_include_1 ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1f76bc4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_1'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_1'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_1'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeeec5284> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef0a8d4c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef0a8d4c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_include_1'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef0a898c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef0a898c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef0a898c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef0a898c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef2c480c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef6a026c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeefeea2c>, <W_TypeObject 'MemoryError' at 0xef4af98c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef96fc2c>, <W_TypeObject 'cinstancemethod' at 0xeefeec8c>, <W_TypeObject 'AttributeError' at 0xef725eac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeda0b8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeda0b8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeda0b8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeda0b8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc687560>> w_obj = <W_TypeObject 'ellipsis' at 0xeeda0b8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeeda0b8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc687560>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeeda0b8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc687560>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc687560>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc687560>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____________ ERROR at setup of AppTestRecompiler.test_include_1b ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1c987d4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_1b'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_1b'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_1b'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_1b'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_1b'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_1b'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_1b'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf0ecfcac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...include_1b'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefb5ccac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefb5ccac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...include_1b'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_1b'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_include_1b'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefb5cbec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefb5cbec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefb5cbec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefb5cbec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeeeba2ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef4b2cec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef4b2a0c>, <W_TypeObject 'MemoryError' at 0xefa70fcc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeebb88cc>, <W_TypeObject 'cinstancemethod' at 0xeef2d2ac>, <W_TypeObject 'AttributeError' at 0xeef1c6ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9d19ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9d19ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9d19ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9d19ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8aad80>> w_obj = <W_TypeObject 'ellipsis' at 0xef9d19ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef9d19ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8aad80>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef9d19ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8aad80>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8aad80>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8aad80>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_include_2 ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf189c72c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_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, 5 meths, kwargs={'item': <AppTestMethod 'test_include_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef0d2144> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef1a70c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef1a70c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_include_2'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeef1a76c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef1a76c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef1a76c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeef1a76c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef8a28ec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefc16c8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xefc160cc>, <W_TypeObject 'MemoryError' at 0xee9bed8c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeef5240c>, <W_TypeObject 'cinstancemethod' at 0xeec0848c>, <W_TypeObject 'AttributeError' at 0xeefc36ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1c36ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1c36ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1c36ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef1c36ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc660c20>> w_obj = <W_TypeObject 'ellipsis' at 0xef1c36ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef1c36ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc660c20>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef1c36ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc660c20>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc660c20>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc660c20>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_include_3 ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1457614>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_3'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_3'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_3'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef4b06e4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeed4010c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeed4010c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_include_3'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeed401ac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeed401ac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeed401ac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeed401ac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeee722ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef01a1cc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef01a46c>, <W_TypeObject 'MemoryError' at 0xeee4b84c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee9a298c>, <W_TypeObject 'cinstancemethod' at 0xef2801cc>, <W_TypeObject 'AttributeError' at 0xeece09ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefc12eec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefc12eec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefc12eec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefc12eec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa456a98>> w_obj = <W_TypeObject 'ellipsis' at 0xefc12eec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xefc12eec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa456a98>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xefc12eec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa456a98>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa456a98>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa456a98>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_include_4 ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf177810c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_4'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_4'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_4'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef0b00f4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef713d2c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef713d2c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_4'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_include_4'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef713bac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef713bac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef713bac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef713bac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeee2768c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef96f26c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeeea15ec>, <W_TypeObject 'MemoryError' at 0xef3596ac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef99a40c>, <W_TypeObject 'cinstancemethod' at 0xeeea15ac>, <W_TypeObject 'AttributeError' at 0xeea677ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefb5e4c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefb5e4c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefb5e4c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefb5e4c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc27f7a8>> w_obj = <W_TypeObject 'ellipsis' at 0xeefb5e4c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeefb5e4c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc27f7a8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeefb5e4c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc27f7a8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc27f7a8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc27f7a8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_include_5 ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf207464c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_5'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_5'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_5'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_5'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_5'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_5'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_5'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef76f0cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_5'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeb983ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeb983ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_5'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_5'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_include_5'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeeb98cac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeb98cac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeb98cac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeeb98cac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeec05e8c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeec085cc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeec0832c>, <W_TypeObject 'MemoryError' at 0xeef862ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeec6f9ac>, <W_TypeObject 'cinstancemethod' at 0xeedc764c>, <W_TypeObject 'AttributeError' at 0xeec1ed0c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef82a24c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef82a24c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef82a24c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef82a24c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc89d060>> w_obj = <W_TypeObject 'ellipsis' at 0xef82a24c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef82a24c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc89d060>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef82a24c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc89d060>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc89d060>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc89d060>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_include_6 ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf0f94ed4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_6'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_6'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_6'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_6'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_6'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_6'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_6'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeef4f414> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_6'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef96672c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef96672c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_6'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_6'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_include_6'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef966dac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef966dac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef966dac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef966dac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeebbb0ec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeed26d0c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeed2622c>, <W_TypeObject 'MemoryError' at 0xef10c04c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeef44c4c>, <W_TypeObject 'cinstancemethod' at 0xeed26bcc>, <W_TypeObject 'AttributeError' at 0xef4e798c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2a7ccc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2a7ccc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2a7ccc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2a7ccc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7cbb10>> w_obj = <W_TypeObject 'ellipsis' at 0xef2a7ccc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef2a7ccc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7cbb10>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef2a7ccc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7cbb10>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7cbb10>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7cbb10>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_include_7 ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf20716f4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_7'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_7'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_7'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_7'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_7'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_7'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_7'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeeaa934c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_7'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeea9392c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeea9392c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_7'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_7'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_include_7'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeea9390c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeea9390c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeea9390c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeea9390c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeefd2a8c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeea8162c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeea8176c>, <W_TypeObject 'MemoryError' at 0xef16bbcc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeef52dac>, <W_TypeObject 'cinstancemethod' at 0xee807b4c>, <W_TypeObject 'AttributeError' at 0xef14e12c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeecb79ec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeecb79ec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeecb79ec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeecb79ec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc79d788>> w_obj = <W_TypeObject 'ellipsis' at 0xeecb79ec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeecb79ec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc79d788>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeecb79ec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc79d788>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc79d788>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc79d788>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_include_8 ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf0f8fe64>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_8'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_8'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_8'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_8'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_8'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_include_8'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_8'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeedceedc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_8'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeed5040c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeed5040c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._include_8'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_include_8'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_include_8'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeed5076c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeed5076c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeed5076c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeed5076c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xefb79d0c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeed22bec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeed2264c>, <W_TypeObject 'MemoryError' at 0xef4a996c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeea7acec>, <W_TypeObject 'cinstancemethod' at 0xeed22aac>, <W_TypeObject 'AttributeError' at 0xeec7cf6c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeec91cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeec91cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeec91cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeec91cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc221dc8>> w_obj = <W_TypeObject 'ellipsis' at 0xeeec91cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeeec91cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc221dc8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeeec91cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc221dc8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc221dc8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc221dc8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_bitfield_basic ____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf0f51f0c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_bitfield_basic'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bitfield_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_bitfield_basic'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bitfield_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_bitfield_basic'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bitfield_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, 5 meths, kwargs={'item': <AppTestMethod 'test_bitfield_basic'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef08c144> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ield_basic'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee9ee1cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee9ee1cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ield_basic'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_bitfield_basic'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_bitfield_basic'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee9eedcc> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee9eedcc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee9eedcc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee9eedcc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeee1128c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef03660c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef0369ec>, <W_TypeObject 'MemoryError' at 0xef03f0ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeefd450c>, <W_TypeObject 'cinstancemethod' at 0xef036eec>, <W_TypeObject 'AttributeError' at 0xef061b4c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeec1fc6c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeec1fc6c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeec1fc6c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeec1fc6c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c64c0>> w_obj = <W_TypeObject 'ellipsis' at 0xeec1fc6c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeec1fc6c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c64c0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeec1fc6c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c64c0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c64c0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c64c0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_incomplete_struct_as_arg _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf0fcec34>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_incomplete_struct_as_arg'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_incomplete_struct_as_arg'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_incomplete_struct_as_arg'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee93bb44> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...uct_as_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef43314c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef43314c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...uct_as_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_incomplete_struct_as_arg'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef433c2c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef433c2c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef433c2c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef433c2c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeee6076c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef2e146c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef2621ec>, <W_TypeObject 'MemoryError' at 0xeeb8ae2c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeed8824c>, <W_TypeObject 'cinstancemethod' at 0xeefc34cc>, <W_TypeObject 'AttributeError' at 0xeec8986c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb2c3ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb2c3ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb2c3ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xefb2c3ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3dbb60>> w_obj = <W_TypeObject 'ellipsis' at 0xefb2c3ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xefb2c3ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3dbb60>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xefb2c3ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3dbb60>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3dbb60>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3dbb60>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_incomplete_struct_as_result _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf0fb3c34>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_result'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_incomplete_struct_as_result'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_result'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_incomplete_struct_as_result'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_result'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_incomplete_struct_as_result'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_result'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeee9e9dc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._as_result'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef309b4c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef309b4c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._as_result'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_result'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_incomplete_struct_as_result'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef30970c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef30970c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef30970c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef30970c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee7d22ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeeae6a0c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeeae6a6c>, <W_TypeObject 'MemoryError' at 0xeee7e56c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeee727cc>, <W_TypeObject 'cinstancemethod' at 0xeeae656c>, <W_TypeObject 'AttributeError' at 0xeeb6020c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef654d8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef654d8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef654d8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef654d8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc69fe20>> w_obj = <W_TypeObject 'ellipsis' at 0xef654d8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef654d8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc69fe20>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef654d8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc69fe20>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc69fe20>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc69fe20>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_incomplete_struct_as_both ______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1413454>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_both'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_incomplete_struct_as_both'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_both'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_incomplete_struct_as_both'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_both'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_incomplete_struct_as_both'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_both'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeef4f7d4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ct_as_both'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef52830c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef52830c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ct_as_both'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_incomplete_struct_as_both'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_incomplete_struct_as_both'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef5282ac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef5282ac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef5282ac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef5282ac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeee38e2c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef58346c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef58374c>, <W_TypeObject 'MemoryError' at 0xee955f2c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef0aec8c>, <W_TypeObject 'cinstancemethod' at 0xef58370c>, <W_TypeObject 'AttributeError' at 0xef6dacec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee13b8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee13b8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee13b8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee13b8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa509098>> w_obj = <W_TypeObject 'ellipsis' at 0xeee13b8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeee13b8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa509098>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeee13b8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa509098>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa509098>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa509098>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _______ ERROR at setup of AppTestRecompiler.test_name_of_unnamed_struct ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf11c379c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_name_of_unnamed_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_name_of_unnamed_struct'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_name_of_unnamed_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_name_of_unnamed_struct'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_name_of_unnamed_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_name_of_unnamed_struct'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_name_of_unnamed_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee7d0edc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...med_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee80722c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee80722c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...med_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_name_of_unnamed_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_name_of_unnamed_struct'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee8071ec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee8071ec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee8071ec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee8071ec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeef768cc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeef8f3cc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xefc16b0c>, <W_TypeObject 'MemoryError' at 0xef24dc0c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef2dca8c>, <W_TypeObject 'cinstancemethod' at 0xeed50a2c>, <W_TypeObject 'AttributeError' at 0xeef3faec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeaa43ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeaa43ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeaa43ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeaa43ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6cf500>> w_obj = <W_TypeObject 'ellipsis' at 0xeeaa43ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeeaa43ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6cf500>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeeaa43ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6cf500>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6cf500>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6cf500>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_address_of_global_var ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1192b8c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_address_of_global_var'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_address_of_global_var'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_address_of_global_var'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeee8207c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef50d4c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef50d4c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_address_of_global_var'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeef50bac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef50bac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef50bac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeef50bac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef1ddd2c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeeb4a9ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeeb4ae0c>, <W_TypeObject 'MemoryError' at 0xef40598c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef93b8ac>, <W_TypeObject 'cinstancemethod' at 0xef047f4c>, <W_TypeObject 'AttributeError' at 0xeecac0ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee7a67ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee7a67ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee7a67ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee7a67ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5e2908>> w_obj = <W_TypeObject 'ellipsis' at 0xee7a67ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee7a67ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5e2908>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee7a67ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5e2908>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5e2908>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5e2908>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_defines__CFFI_ ____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf16ccd84>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_defines__CFFI_'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_defines__CFFI_'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_defines__CFFI_'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_defines__CFFI_'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_defines__CFFI_'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_defines__CFFI_'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_defines__CFFI_'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef0435cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nes__CFFI_'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeecf086c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeecf086c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nes__CFFI_'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_defines__CFFI_'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_defines__CFFI_'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeecf026c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeecf026c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeecf026c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeecf026c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeea8402c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef9527ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef9520cc>, <W_TypeObject 'MemoryError' at 0xeeb3d8ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeed16a8c>, <W_TypeObject 'cinstancemethod' at 0xef4bed4c>, <W_TypeObject 'AttributeError' at 0xeeabc46c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5b7b8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5b7b8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5b7b8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5b7b8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb715170>> w_obj = <W_TypeObject 'ellipsis' at 0xee5b7b8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee5b7b8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb715170>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee5b7b8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb715170>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb715170>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb715170>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____________ ERROR at setup of AppTestRecompiler.test_unpack_args _____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf2004ae4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unpack_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unpack_args'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unpack_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unpack_args'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unpack_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unpack_args'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unpack_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xefc13b94> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...npack_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef8ad60c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef8ad60c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...npack_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_unpack_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_unpack_args'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef8ad06c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef8ad06c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef8ad06c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef8ad06c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef1e5f4c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef4b4d0c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef4b436c>, <W_TypeObject 'MemoryError' at 0xeeaa8ccc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeef50c6c>, <W_TypeObject 'cinstancemethod' at 0xeeab020c>, <W_TypeObject 'AttributeError' at 0xee9ca24c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8740ec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8740ec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8740ec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef8740ec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc182c48>> w_obj = <W_TypeObject 'ellipsis' at 0xef8740ec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef8740ec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc182c48>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef8740ec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc182c48>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc182c48>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc182c48>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_address_of_function _________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf16d6f0c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_address_of_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_address_of_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_address_of_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, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeec0c48c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef96f14c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef96f14c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_address_of_function'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef96f38c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef96f38c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef96f38c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef96f38c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeec08d8c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef91514c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef9158cc>, <W_TypeObject 'MemoryError' at 0xee9c51cc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef5ca3ac>, <W_TypeObject 'cinstancemethod' at 0xeeca7ccc>, <W_TypeObject 'AttributeError' at 0xef79cdec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee3828c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee3828c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee3828c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee3828c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3e5ba0>> w_obj = <W_TypeObject 'ellipsis' at 0xeee3828c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeee3828c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3e5ba0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeee3828c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3e5ba0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3e5ba0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3e5ba0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___ ERROR at setup of AppTestRecompiler.test_address_of_function_with_struct ___ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1ec7064>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_function_with_struct...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_address_of_function_with_struct'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_function_with_struct...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_address_of_function_with_struct'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_function_with_struct...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_address_of_function_with_struct'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_function_with_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeef4f57c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ith_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef2069cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef2069cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ith_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_address_of_function_with_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_address_of_function_with_struct'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef20614c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef20614c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef20614c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef20614c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeeb4a54c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef7a6dcc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef7a6dec>, <W_TypeObject 'MemoryError' at 0xeebafdac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeef79dcc>, <W_TypeObject 'cinstancemethod' at 0xee9bd9cc>, <W_TypeObject 'AttributeError' at 0xef534b2c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeff55cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeff55cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeff55cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeff55cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc9214f0>> w_obj = <W_TypeObject 'ellipsis' at 0xeeff55cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeeff55cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc9214f0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeeff55cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc9214f0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc9214f0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc9214f0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_issue198 _______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf336956c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_issue198'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_issue198'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_issue198'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_issue198'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_issue198'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_issue198'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_issue198'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeed34e8c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_issue198'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef3d67ec> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef3d67ec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_issue198'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_issue198'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_issue198'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef3d69ec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef3d69ec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef3d69ec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef3d69ec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef0e64ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeeddd46c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeeddd80c>, <W_TypeObject 'MemoryError' at 0xeeb9ddac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xefa84e2c>, <W_TypeObject 'cinstancemethod' at 0xeef7886c>, <W_TypeObject 'AttributeError' at 0xee90aa0c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef77488c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef77488c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef77488c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef77488c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb723430>> w_obj = <W_TypeObject 'ellipsis' at 0xef77488c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef77488c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb723430>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef77488c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb723430>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb723430>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb723430>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _ ERROR at setup of AppTestRecompiler.test_constant_is_not_a_compiler_constant _ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3a8287c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_is_not_a_compiler_cons...': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_is_not_a_compiler_constant'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_is_not_a_compiler_cons...': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_is_not_a_compiler_constant'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_is_not_a_compiler_cons...': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_is_not_a_compiler_constant'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_is_not_a_compiler_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef1c8d74> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...r_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef01a58c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef01a58c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...r_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_is_not_a_compiler_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_constant_is_not_a_compiler_constant'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef01a98c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef01a98c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef01a98c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef01a98c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef62a8cc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee778e8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee7781ec>, <W_TypeObject 'MemoryError' at 0xee7e504c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef57d18c>, <W_TypeObject 'cinstancemethod' at 0xee7f01ec>, <W_TypeObject 'AttributeError' at 0xeeec39cc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee9c54ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee9c54ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee9c54ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee9c54ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd1a248>> w_obj = <W_TypeObject 'ellipsis' at 0xee9c54ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee9c54ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd1a248>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee9c54ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd1a248>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd1a248>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd1a248>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_constant_of_unknown_size _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3a54144>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_of_unknown_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_of_unknown_size'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_of_unknown_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_of_unknown_size'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_of_unknown_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_of_unknown_size'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_of_unknown_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee97b6e4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...known_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef72506c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef72506c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...known_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_of_unknown_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_constant_of_unknown_size'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef72518c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef72518c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef72518c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef72518c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee4e466c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xefb2426c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xefb24bec>, <W_TypeObject 'MemoryError' at 0xeed2626c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee868b6c>, <W_TypeObject 'cinstancemethod' at 0xefb2478c>, <W_TypeObject 'AttributeError' at 0xef59688c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee082cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee082cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee082cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee082cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc89a3f8>> w_obj = <W_TypeObject 'ellipsis' at 0xeee082cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeee082cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc89a3f8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeee082cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc89a3f8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc89a3f8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc89a3f8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_variable_of_unknown_size _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf25367d4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_variable_of_unknown_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_variable_of_unknown_size'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_variable_of_unknown_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_variable_of_unknown_size'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_variable_of_unknown_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_variable_of_unknown_size'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_variable_of_unknown_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef043a54> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...known_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeb9564c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeb9564c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...known_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_variable_of_unknown_size'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_variable_of_unknown_size'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeeb9594c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeb9594c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeb9594c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeeb9594c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef335b4c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee86854c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee868d4c>, <W_TypeObject 'MemoryError' at 0xeeeb076c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee67b0ac>, <W_TypeObject 'cinstancemethod' at 0xee7a9fac>, <W_TypeObject 'AttributeError' at 0xee7b1fec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2b5d6c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2b5d6c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2b5d6c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef2b5d6c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc70ea88>> w_obj = <W_TypeObject 'ellipsis' at 0xef2b5d6c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef2b5d6c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc70ea88>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef2b5d6c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc70ea88>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc70ea88>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc70ea88>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ERROR at setup of AppTestRecompiler.test_constant_of_value_unknown_to_the_compiler self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3b95684>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_of_value_unknown_to_th...ultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_of_value_unknown_to_the_compiler'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_of_value_unknown_to_th...ultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_of_value_unknown_to_the_compiler'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_of_value_unknown_to_th...ultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constant_of_value_unknown_to_the_compiler'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_of_value_unknown_to_the_compiler'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeef48eb4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...e_compiler'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeea9e0c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeea9e0c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...e_compiler'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_constant_of_value_unknown_to_the_compiler'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_constant_of_value_unknown_to_the_compiler'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeeea954c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeea954c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeea954c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeeea954c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeed6b84c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee884f8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee88418c>, <W_TypeObject 'MemoryError' at 0xee47c58c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee83d66c>, <W_TypeObject 'cinstancemethod' at 0xee823aec>, <W_TypeObject 'AttributeError' at 0xee63d1ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeead4b0c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeead4b0c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeead4b0c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeead4b0c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc90a058>> w_obj = <W_TypeObject 'ellipsis' at 0xeead4b0c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeead4b0c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc90a058>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeead4b0c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc90a058>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc90a058>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc90a058>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____ ERROR at setup of AppTestRecompiler.test_call_with_incomplete_structs _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf173b17c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_incomplete_structs'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_incomplete_structs'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_incomplete_structs'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_incomplete_structs'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_incomplete_structs'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_incomplete_structs'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_incomplete_structs'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeea3ff54> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...te_structs'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef57d6ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef57d6ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...te_structs'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_incomplete_structs'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_with_incomplete_structs'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef57d8ec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef57d8ec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef57d8ec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef57d8ec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeeacf66c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee7d45ec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee7d49ec>, <W_TypeObject 'MemoryError' at 0xeec7cbec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee9a24ec>, <W_TypeObject 'cinstancemethod' at 0xeeea3a2c>, <W_TypeObject 'AttributeError' at 0xeeb1974c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef0937ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef0937ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef0937ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef0937ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c4778>> w_obj = <W_TypeObject 'ellipsis' at 0xef0937ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef0937ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c4778>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef0937ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c4778>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c4778>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c4778>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_struct_array_guess_length_2 _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf13e7c6c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_array_guess_length_2'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_struct_array_guess_length_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_array_guess_length_2'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_struct_array_guess_length_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_array_guess_length_2'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_struct_array_guess_length_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, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_array_guess_length_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeeacd7d4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...s_length_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee58014c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee58014c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...s_length_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_array_guess_length_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_struct_array_guess_length_2'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee58028c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee58028c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee58028c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee58028c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef67c18c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee545eac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee54532c>, <W_TypeObject 'MemoryError' at 0xef82afac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeed263ec>, <W_TypeObject 'cinstancemethod' at 0xee329f6c>, <W_TypeObject 'AttributeError' at 0xeef1c2ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9c982c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9c982c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9c982c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9c982c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7d82d8>> w_obj = <W_TypeObject 'ellipsis' at 0xef9c982c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef9c982c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7d82d8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef9c982c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7d82d8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7d82d8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7d82d8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_struct_array_guess_length_3 _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3c529cc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_array_guess_length_3'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_struct_array_guess_length_3'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_array_guess_length_3'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_struct_array_guess_length_3'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_array_guess_length_3'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_struct_array_guess_length_3'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_array_guess_length_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeebd8af4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...s_length_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeadf24c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeadf24c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...s_length_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_array_guess_length_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_struct_array_guess_length_3'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeeadf34c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeadf34c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeadf34c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeeadf34c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee7ff98c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeeb43d6c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeeb43c2c>, <W_TypeObject 'MemoryError' at 0xeee0b88c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee64d78c>, <W_TypeObject 'cinstancemethod' at 0xee7ddb6c>, <W_TypeObject 'AttributeError' at 0xee67238c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee341d2c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee341d2c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee341d2c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee341d2c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc77c3a8>> w_obj = <W_TypeObject 'ellipsis' at 0xee341d2c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee341d2c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc77c3a8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee341d2c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc77c3a8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc77c3a8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc77c3a8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_global_var_array_2 __________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf133bdbc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_array_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_global_var_array_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_array_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_global_var_array_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_array_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_global_var_array_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, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_array_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee4d575c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ar_array_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef44dac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef44dac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ar_array_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_global_var_array_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_global_var_array_2'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeef44a0c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef44a0c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef44a0c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeef44a0c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeea3c88c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeea3442c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeea3454c>, <W_TypeObject 'MemoryError' at 0xeeafba0c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee4f41ac>, <W_TypeObject 'cinstancemethod' at 0xeea340ac>, <W_TypeObject 'AttributeError' at 0xef4faf6c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef141f4c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef141f4c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef141f4c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef141f4c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd028d0>> w_obj = <W_TypeObject 'ellipsis' at 0xef141f4c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef141f4c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd028d0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef141f4c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd028d0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd028d0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd028d0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __________ ERROR at setup of AppTestRecompiler.test_some_integer_type __________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf17495dc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_some_integer_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_some_integer_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_some_integer_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_some_integer_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_some_integer_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_some_integer_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, 5 meths, kwargs={'item': <AppTestMethod 'test_some_integer_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef4d44dc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...teger_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeebb83cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeebb83cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...teger_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_some_integer_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_some_integer_type'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeebb880c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeebb880c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeebb880c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeebb880c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeee515ec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee7e5b2c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee7e5bac>, <W_TypeObject 'MemoryError' at 0xef52de8c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef76d7ec>, <W_TypeObject 'cinstancemethod' at 0xef903f6c>, <W_TypeObject 'AttributeError' at 0xef49a06c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb90e0c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb90e0c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb90e0c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb90e0c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc75c520>> w_obj = <W_TypeObject 'ellipsis' at 0xeeb90e0c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeeb90e0c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc75c520>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeeb90e0c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc75c520>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc75c520>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc75c520>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestRecompiler.test_issue200 _______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf124ea04>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_issue200'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_issue200'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_issue200'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_issue200'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_issue200'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_issue200'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_issue200'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeee8234c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_issue200'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef90edec> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef90edec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_issue200'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_issue200'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_issue200'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef9db68c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef9db68c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef9db68c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef9db68c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef075a6c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeeddd4ec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeeddde2c>, <W_TypeObject 'MemoryError' at 0xeef1cfec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee55776c>, <W_TypeObject 'cinstancemethod' at 0xeeddd86c>, <W_TypeObject 'AttributeError' at 0xeeb2a0cc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee4256c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee4256c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee4256c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeee4256c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc11e2a8>> w_obj = <W_TypeObject 'ellipsis' at 0xeee4256c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeee4256c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc11e2a8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeee4256c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc11e2a8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc11e2a8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc11e2a8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_alignment_of_longlong ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf26b1614>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_alignment_of_longlong'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_alignment_of_longlong'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_alignment_of_longlong'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_alignment_of_longlong'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_alignment_of_longlong'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_alignment_of_longlong'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_alignment_of_longlong'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeeb4793c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_longlong'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee47d10c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee47d10c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_longlong'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_alignment_of_longlong'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_alignment_of_longlong'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee47d2ec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee47d2ec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee47d2ec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee47d2ec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeee41c4c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef9152ec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef915d0c>, <W_TypeObject 'MemoryError' at 0xee8eb4ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeeb889ec>, <W_TypeObject 'cinstancemethod' at 0xef57182c>, <W_TypeObject 'AttributeError' at 0xee65c3cc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee4de38c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee4de38c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee4de38c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee4de38c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3c88c8>> w_obj = <W_TypeObject 'ellipsis' at 0xee4de38c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee4de38c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3c88c8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee4de38c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3c88c8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3c88c8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3c88c8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_import_from_lib ___________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf2d2bbfc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_import_from_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_import_from_lib'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_import_from_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_import_from_lib'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_import_from_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_import_from_lib'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_import_from_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeecdbcfc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_from_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef2064cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef2064cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_from_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_import_from_lib'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_from_lib'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef20624c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef20624c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef20624c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef20624c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee71352c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee64d76c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee3413ec>, <W_TypeObject 'MemoryError' at 0xef8ad88c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeecb490c>, <W_TypeObject 'cinstancemethod' at 0xef068bac>, <W_TypeObject 'AttributeError' at 0xeef5e20c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeebb898c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeebb898c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeebb898c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeebb898c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc79e3d8>> w_obj = <W_TypeObject 'ellipsis' at 0xeebb898c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeebb898c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc79e3d8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeebb898c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc79e3d8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc79e3d8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc79e3d8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_macro_var_callback __________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf26c6a3c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro_var_callback'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macro_var_callback'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro_var_callback'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macro_var_callback'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro_var_callback'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macro_var_callback'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro_var_callback'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef08c414> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...r_callback'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee6097cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee6097cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...r_callback'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macro_var_callback'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_var_callback'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee6094ec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee6094ec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee6094ec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee6094ec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeeeb018c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee5cdaec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee5cd78c>, <W_TypeObject 'MemoryError' at 0xee932a2c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee7fd82c>, <W_TypeObject 'cinstancemethod' at 0xee5cdb2c>, <W_TypeObject 'AttributeError' at 0xee8f304c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5b386c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5b386c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5b386c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5b386c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3e8190>> w_obj = <W_TypeObject 'ellipsis' at 0xee5b386c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee5b386c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3e8190>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee5b386c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3e8190>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3e8190>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc3e8190>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____________ ERROR at setup of AppTestRecompiler.test_const_fields _____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf115bc34>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_fields'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_fields'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_fields'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeea0d8c4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nst_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeb0630c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeb0630c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nst_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_const_fields'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeeb0612c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeb0612c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeb0612c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeeb0612c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeed175ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeeddfecc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeeddf4ac>, <W_TypeObject 'MemoryError' at 0xee87c84c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeebae6ac>, <W_TypeObject 'cinstancemethod' at 0xee364b6c>, <W_TypeObject 'AttributeError' at 0xeec1adac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef03fb2c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef03fb2c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef03fb2c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef03fb2c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6ecf00>> w_obj = <W_TypeObject 'ellipsis' at 0xef03fb2c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef03fb2c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6ecf00>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef03fb2c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6ecf00>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6ecf00>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6ecf00>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_restrict_fields ___________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf134bca4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_restrict_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_restrict_fields'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_restrict_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_restrict_fields'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_restrict_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_restrict_fields'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_restrict_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee5ecedc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ict_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeea8efec> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeea8efec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ict_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_restrict_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_restrict_fields'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeea8eccc> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeea8eccc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeea8eccc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeea8eccc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee72f9cc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee97ccec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee908b0c>, <W_TypeObject 'MemoryError' at 0xeea9396c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee7a9b8c>, <W_TypeObject 'cinstancemethod' at 0xee5cdeac>, <W_TypeObject 'AttributeError' at 0xeea6784c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefd444c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefd444c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefd444c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeefd444c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7cd0c8>> w_obj = <W_TypeObject 'ellipsis' at 0xeefd444c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeefd444c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7cd0c8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeefd444c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7cd0c8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7cd0c8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7cd0c8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_volatile_fields ___________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf11f5304>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_volatile_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_volatile_fields'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_volatile_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_volatile_fields'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_volatile_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_volatile_fields'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_volatile_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeeb17414> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ile_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef7d2bac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef7d2bac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ile_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_volatile_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_volatile_fields'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef7d2f8c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef7d2f8c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef7d2f8c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef7d2f8c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeeab068c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee4a14ec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee4a18cc>, <W_TypeObject 'MemoryError' at 0xee33b34c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee8a66ec>, <W_TypeObject 'cinstancemethod' at 0xee77066c>, <W_TypeObject 'AttributeError' at 0xee6728ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee7459ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee7459ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee7459ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee7459ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa492ae8>> w_obj = <W_TypeObject 'ellipsis' at 0xee7459ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee7459ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa492ae8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee7459ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa492ae8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa492ae8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa492ae8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_const_array_fields __________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3c10614>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_array_fields'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_array_fields'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_array_fields'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee4f1edc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ray_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee73140c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee73140c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ray_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_const_array_fields'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee731e8c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee731e8c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee731e8c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee731e8c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeea81ccc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee809aac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee80920c>, <W_TypeObject 'MemoryError' at 0xeeea11cc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee91616c>, <W_TypeObject 'cinstancemethod' at 0xee743f0c>, <W_TypeObject 'AttributeError' at 0xee47ddcc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee353cec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee353cec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee353cec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee353cec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c4280>> w_obj = <W_TypeObject 'ellipsis' at 0xee353cec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee353cec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c4280>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee353cec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c4280>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c4280>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7c4280>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____ ERROR at setup of AppTestRecompiler.test_const_array_fields_varlength _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3be4294>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields_varlength'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_array_fields_varlength'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields_varlength'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_array_fields_varlength'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields_varlength'>,...icall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_array_fields_varlength'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields_varlength'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee7cf98c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._varlength'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef53442c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef53442c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._varlength'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields_varlength'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_const_array_fields_varlength'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef53424c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef53424c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef53424c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef53424c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee71032c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee82ae8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef3da84c>, <W_TypeObject 'MemoryError' at 0xee9f5d6c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeebc842c>, <W_TypeObject 'cinstancemethod' at 0xee3dd14c>, <W_TypeObject 'AttributeError' at 0xee34766c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef52d5ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef52d5ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef52d5ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef52d5ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7e6068>> w_obj = <W_TypeObject 'ellipsis' at 0xef52d5ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef52d5ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7e6068>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef52d5ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7e6068>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7e6068>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7e6068>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __ ERROR at setup of AppTestRecompiler.test_const_array_fields_unknownlength ___ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf194d87c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields_unknownlengt...l__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_array_fields_unknownlength'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields_unknownlengt...l__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_array_fields_unknownlength'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields_unknownlengt...l__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_array_fields_unknownlength'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields_unknownlength'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee81e7d4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nownlength'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee2ac6ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee2ac6ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nownlength'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_array_fields_unknownlength'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_const_array_fields_unknownlength'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee2ac70c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee2ac70c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee2ac70c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee2ac70c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee8a680c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee64c56c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee64cb6c>, <W_TypeObject 'MemoryError' at 0xee83a7ac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee51412c>, <W_TypeObject 'cinstancemethod' at 0xeeb8aa0c>, <W_TypeObject 'AttributeError' at 0xee70798c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee4dcf6c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee4dcf6c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee4dcf6c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee4dcf6c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc24bd98>> w_obj = <W_TypeObject 'ellipsis' at 0xee4dcf6c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee4dcf6c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc24bd98>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee4dcf6c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc24bd98>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc24bd98>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc24bd98>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_const_function_args _________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf191bd4c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_function_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_function_args'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_function_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_function_args'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_function_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_function_args'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_function_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee8949dc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ction_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee16f5cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee16f5cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ction_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_function_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_const_function_args'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee16f40c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee16f40c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee16f40c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee16f40c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee95d38c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee5750ec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeef78aac>, <W_TypeObject 'MemoryError' at 0xee52e22c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeeea9bec>, <W_TypeObject 'cinstancemethod' at 0xeef784ac>, <W_TypeObject 'AttributeError' at 0xee6e346c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee2557ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee2557ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee2557ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee2557ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb9e098>> w_obj = <W_TypeObject 'ellipsis' at 0xee2557ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee2557ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb9e098>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee2557ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb9e098>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb9e098>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb9e098>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_const_function_type_args _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf15bdd14>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_function_type_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_function_type_args'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_function_type_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_function_type_args'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_function_type_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_function_type_args'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_function_type_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xef94a11c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._type_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeebc884c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeebc884c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._type_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_function_type_args'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_const_function_type_args'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeebc8cec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeebc8cec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeebc8cec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeebc8cec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee707f2c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeea67b8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeea673ac>, <W_TypeObject 'MemoryError' at 0xefa70f4c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeec1af0c>, <W_TypeObject 'cinstancemethod' at 0xeefd20ec>, <W_TypeObject 'AttributeError' at 0xee31318c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9520cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9520cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9520cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef9520cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc99b558>> w_obj = <W_TypeObject 'ellipsis' at 0xef9520cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef9520cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc99b558>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef9520cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc99b558>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc99b558>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc99b558>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_const_constant ____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1856e64>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_constant'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_constant'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_constant'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xefadb824> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee3b8a2c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee3b8a2c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_constant'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_const_constant'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee3b8bec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee3b8bec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee3b8bec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee3b8bec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee31902c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee72ebac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee72e3ac>, <W_TypeObject 'MemoryError' at 0xee7a9cec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee211dcc>, <W_TypeObject 'cinstancemethod' at 0xee58c40c>, <W_TypeObject 'AttributeError' at 0xee74c04c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee25148c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee25148c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee25148c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee25148c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5d4b08>> w_obj = <W_TypeObject 'ellipsis' at 0xee25148c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee25148c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5d4b08>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee25148c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5d4b08>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5d4b08>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc5d4b08>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __________ ERROR at setup of AppTestRecompiler.test_const_via_typedef __________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf324c534>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_via_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_via_typedef'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_via_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_via_typedef'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_via_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_const_via_typedef'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_via_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee3cda04> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ia_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefb09d6c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefb09d6c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ia_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_const_via_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_const_via_typedef'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefb09f0c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefb09f0c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefb09f0c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefb09f0c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee543b2c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeea81fcc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeea811cc>, <W_TypeObject 'MemoryError' at 0xee73abac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeeb88ccc>, <W_TypeObject 'cinstancemethod' at 0xef51df4c>, <W_TypeObject 'AttributeError' at 0xefb245ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee472f0c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee472f0c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee472f0c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee472f0c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca23f28>> w_obj = <W_TypeObject 'ellipsis' at 0xee472f0c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee472f0c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca23f28>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee472f0c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca23f28>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca23f28>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca23f28>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_win32_calling_convention_0 ______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf202c5dc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_0'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_0'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_0'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_0'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_0'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_0'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_0'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee09fc5c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nvention_0'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeed8864c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeed8864c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nvention_0'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_0'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_win32_calling_convention_0'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeefaeb4c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeefaeb4c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeefaeb4c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeefaeb4c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef75582c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef2dc40c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef96034c>, <W_TypeObject 'MemoryError' at 0xee8b128c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef4e0a4c>, <W_TypeObject 'cinstancemethod' at 0xee489c6c>, <W_TypeObject 'AttributeError' at 0xeeefdcac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedfbc9ec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedfbc9ec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedfbc9ec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedfbc9ec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6b4db0>> w_obj = <W_TypeObject 'ellipsis' at 0xedfbc9ec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedfbc9ec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6b4db0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedfbc9ec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6b4db0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6b4db0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc6b4db0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_win32_calling_convention_1 ______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf18799cc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_1'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_1'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_1'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_1'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_1'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_1'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee5ec16c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nvention_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee9be24c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee9be24c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nvention_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_win32_calling_convention_1'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee9be50c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee9be50c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee9be50c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee9be50c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee3dde6c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee6b69ec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee6b652c>, <W_TypeObject 'MemoryError' at 0xee22912c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee9bd02c>, <W_TypeObject 'cinstancemethod' at 0xee6b6ccc>, <W_TypeObject 'AttributeError' at 0xeeb9844c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb4810c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb4810c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb4810c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb4810c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd025d8>> w_obj = <W_TypeObject 'ellipsis' at 0xeeb4810c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeeb4810c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd025d8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeeb4810c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd025d8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd025d8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbd025d8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_win32_calling_convention_2 ______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1b46b8c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_2'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_2'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_2'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_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, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee222af4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nvention_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef068dac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef068dac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nvention_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_2'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_win32_calling_convention_2'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef06808c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef06808c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef06808c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef06808c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee203c6c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee56e7ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee56e2ec>, <W_TypeObject 'MemoryError' at 0xef134fcc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee3e74ec>, <W_TypeObject 'cinstancemethod' at 0xee56e34c>, <W_TypeObject 'AttributeError' at 0xeea550ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeccabcc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeccabcc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeccabcc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeccabcc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcab1a08>> w_obj = <W_TypeObject 'ellipsis' at 0xeeccabcc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeeccabcc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcab1a08>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeeccabcc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcab1a08>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcab1a08>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcab1a08>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_win32_calling_convention_3 ______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1b18fb4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_3'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_3'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_3'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_3'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_3'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_win32_calling_convention_3'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee894dec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nvention_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee19548c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee19548c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nvention_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_win32_calling_convention_3'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_win32_calling_convention_3'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee19554c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee19554c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee19554c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee19554c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef57dfcc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee34a0ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee34a14c>, <W_TypeObject 'MemoryError' at 0xee0546ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee4b8f2c>, <W_TypeObject 'cinstancemethod' at 0xeef1a52c>, <W_TypeObject 'AttributeError' at 0xee614a0c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee04280c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee04280c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee04280c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee04280c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8d1f10>> w_obj = <W_TypeObject 'ellipsis' at 0xee04280c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee04280c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8d1f10>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee04280c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8d1f10>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8d1f10>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8d1f10>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____________ ERROR at setup of AppTestRecompiler.test_share_FILE ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1f3310c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_share_FILE'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_share_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_share_FILE'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_share_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_share_FILE'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_share_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, 5 meths, kwargs={'item': <AppTestMethod 'test_share_FILE'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee310824> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...share_FILE'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee12d4ec> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee12d4ec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...share_FILE'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_share_FILE'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_share_FILE'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee12d38c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee12d38c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee12d38c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee12d38c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee24eacc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xedd5a1ec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xedd5aaec>, <W_TypeObject 'MemoryError' at 0xefb2484c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee76362c>, <W_TypeObject 'cinstancemethod' at 0xedd5a3ac>, <W_TypeObject 'AttributeError' at 0xee5432ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee46cbcc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee46cbcc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee46cbcc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee46cbcc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbbad8a0>> w_obj = <W_TypeObject 'ellipsis' at 0xee46cbcc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee46cbcc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbbad8a0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee46cbcc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbbad8a0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbbad8a0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbbad8a0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_extern_python_1 ___________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf21800d4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_1'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_1'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_1'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee46ffcc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...n_python_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeee0d6c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeee0d6c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...n_python_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_1'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_extern_python_1'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeeee044c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeee044c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeee044c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeeee044c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeea34acc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee63f6ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee63ff4c>, <W_TypeObject 'MemoryError' at 0xee474d6c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee72f2ac>, <W_TypeObject 'cinstancemethod' at 0xee63f1ac>, <W_TypeObject 'AttributeError' at 0xeefe19ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef5716cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef5716cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef5716cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xef5716cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc76fbc8>> w_obj = <W_TypeObject 'ellipsis' at 0xef5716cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xef5716cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc76fbc8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xef5716cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc76fbc8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc76fbc8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc76fbc8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_extern_python_bogus_name _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1b3709c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_bogus_name'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_bogus_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_bogus_name'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_bogus_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_bogus_name'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_bogus_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, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_bogus_name'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeee84e64> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...bogus_name'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef3f32c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeef3f32c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...bogus_name'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_bogus_name'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_extern_python_bogus_name'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeef3faec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef3faec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeef3faec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeef3faec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef770f4c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee543b6c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee54390c>, <W_TypeObject 'MemoryError' at 0xef2e146c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee554a2c>, <W_TypeObject 'cinstancemethod' at 0xee0606ec>, <W_TypeObject 'AttributeError' at 0xee249fac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedf06cac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedf06cac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedf06cac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedf06cac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb232e8>> w_obj = <W_TypeObject 'ellipsis' at 0xedf06cac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedf06cac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb232e8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedf06cac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb232e8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb232e8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb232e8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___ ERROR at setup of AppTestRecompiler.test_extern_python_bogus_result_type ___ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf20426f4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_bogus_result_type...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_bogus_result_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_bogus_result_type...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_bogus_result_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_bogus_result_type...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_bogus_result_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, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_bogus_result_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee81e554> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...esult_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee76b64c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee76b64c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...esult_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_bogus_result_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_extern_python_bogus_result_type'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee76bacc> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee76bacc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee76bacc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee76bacc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeecb744c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee064e0c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee06462c>, <W_TypeObject 'MemoryError' at 0xee48682c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee73e08c>, <W_TypeObject 'cinstancemethod' at 0xef01a88c>, <W_TypeObject 'AttributeError' at 0xef4b24ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee34a28c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee34a28c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee34a28c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee34a28c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8e0d60>> w_obj = <W_TypeObject 'ellipsis' at 0xee34a28c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee34a28c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8e0d60>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee34a28c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8e0d60>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8e0d60>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8e0d60>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _______ ERROR at setup of AppTestRecompiler.test_extern_python_redefine ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf217b48c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_redefine'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_redefine'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_redefine'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_redefine'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_redefine'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_redefine'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_redefine'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee3a1c0c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...n_redefine'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeabc08c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeabc08c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...n_redefine'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_redefine'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_extern_python_redefine'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeeabc26c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeabc26c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeabc26c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeeabc26c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeeb383ec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee2dfd2c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee2df40c>, <W_TypeObject 'MemoryError' at 0xee198d2c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee6bfdcc>, <W_TypeObject 'cinstancemethod' at 0xee2df3ec>, <W_TypeObject 'AttributeError' at 0xee1ae80c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1ceb6c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1ceb6c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1ceb6c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1ceb6c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc45bc0>> w_obj = <W_TypeObject 'ellipsis' at 0xee1ceb6c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee1ceb6c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc45bc0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee1ceb6c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc45bc0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc45bc0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc45bc0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_extern_python_struct _________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf35156f4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_struct'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_struct'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_struct'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedfccfa4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...hon_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedf15ccc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedf15ccc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...hon_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_extern_python_struct'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xedf1542c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedf1542c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedf1542c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xedf1542c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee353ccc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xedd9dc0c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xedd9d06c>, <W_TypeObject 'MemoryError' at 0xede81d6c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee24e40c>, <W_TypeObject 'cinstancemethod' at 0xedf42c8c>, <W_TypeObject 'AttributeError' at 0xeeab068c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1406cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1406cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1406cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1406cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7324c8>> w_obj = <W_TypeObject 'ellipsis' at 0xee1406cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee1406cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7324c8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee1406cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7324c8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7324c8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc7324c8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_extern_python_long_double ______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf21c9f44>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_long_double'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_long_double'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_long_double'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_long_double'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_long_double'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_long_double'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_long_double'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee4b0914> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ong_double'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef5f9eac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef5f9eac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ong_double'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_long_double'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_extern_python_long_double'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef79096c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef79096c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef79096c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef79096c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xedcea7cc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee054dac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee054d4c>, <W_TypeObject 'MemoryError' at 0xee1a264c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeeb4d4ec>, <W_TypeObject 'cinstancemethod' at 0xee054c6c>, <W_TypeObject 'AttributeError' at 0xee412b8c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee673a2c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee673a2c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee673a2c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee673a2c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd36990>> w_obj = <W_TypeObject 'ellipsis' at 0xee673a2c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee673a2c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd36990>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee673a2c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd36990>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd36990>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd36990>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _______ ERROR at setup of AppTestRecompiler.test_extern_python_signature _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1f66614>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_signature'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_signature'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_signature'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_signature'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_signature'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_signature'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_signature'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedffb52c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._signature'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeee80dcc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeee80dcc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._signature'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_signature'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_extern_python_signature'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeee80bec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeee80bec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeee80bec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeee80bec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee23d10c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee0fb1cc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee0fb7ac>, <W_TypeObject 'MemoryError' at 0xee56d4ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeebf650c>, <W_TypeObject 'cinstancemethod' at 0xeecacc4c>, <W_TypeObject 'AttributeError' at 0xedf08dcc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee65226c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee65226c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee65226c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee65226c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc910250>> w_obj = <W_TypeObject 'ellipsis' at 0xee65226c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee65226c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc910250>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee65226c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc910250>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc910250>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc910250>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_extern_python_errors _________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf22dddbc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_errors'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_errors'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_errors'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_errors'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_errors'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_errors'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_errors'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xede67e8c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...hon_errors'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee9bd5cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee9bd5cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...hon_errors'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_errors'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_extern_python_errors'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee9bd5ec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee9bd5ec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee9bd5ec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee9bd5ec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeddd318c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee43a38c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee43ab8c>, <W_TypeObject 'MemoryError' at 0xee31edac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeeb7ffec>, <W_TypeObject 'cinstancemethod' at 0xee43af2c>, <W_TypeObject 'AttributeError' at 0xee66bb6c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedda56cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedda56cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedda56cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedda56cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcac1a90>> w_obj = <W_TypeObject 'ellipsis' at 0xedda56cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedda56cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcac1a90>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedda56cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcac1a90>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcac1a90>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcac1a90>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_extern_python_stdcall ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf29f1b1c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_stdcall'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_stdcall'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_stdcall'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_stdcall'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_stdcall'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_extern_python_stdcall'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_stdcall'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee539284> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...on_stdcall'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee6063ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee6063ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...on_stdcall'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_extern_python_stdcall'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_extern_python_stdcall'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee6060ec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee6060ec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee6060ec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee6060ec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xedb3aeec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee0375ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee0373cc>, <W_TypeObject 'MemoryError' at 0xedc4b04c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee2e57ac>, <W_TypeObject 'cinstancemethod' at 0xede4514c>, <W_TypeObject 'AttributeError' at 0xeedb14ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedff1b2c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedff1b2c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedff1b2c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedff1b2c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc24b080>> w_obj = <W_TypeObject 'ellipsis' at 0xedff1b2c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedff1b2c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc24b080>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedff1b2c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc24b080>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc24b080>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc24b080>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_introspect_function _________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1d0787c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_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, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee2a7824> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeed082c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeed082c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_function'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_function'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee33b4ac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee33b4ac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee33b4ac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee33b4ac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef36660c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee15cf0c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee15cdec>, <W_TypeObject 'MemoryError' at 0xeddc12ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee1ae26c>, <W_TypeObject 'cinstancemethod' at 0xee15c4ac>, <W_TypeObject 'AttributeError' at 0xef4b206c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb06d0c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb06d0c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb06d0c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeeb06d0c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb0e618>> w_obj = <W_TypeObject 'ellipsis' at 0xeeb06d0c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeeb06d0c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb0e618>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeeb06d0c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb0e618>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb0e618>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb0e618>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_introspect_global_var ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf30be8ec>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_global_var'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_global_var'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_global_var'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedee1194> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee3b802c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee3b802c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_global_var'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_global_var'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee3b8b0c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee3b8b0c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee3b8b0c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee3b8b0c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeebf20ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee7e5bac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee7e554c>, <W_TypeObject 'MemoryError' at 0xedfbb8cc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef9717cc>, <W_TypeObject 'cinstancemethod' at 0xee09748c>, <W_TypeObject 'AttributeError' at 0xee4b8a0c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1955ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1955ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1955ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee1955ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcea7b08>> w_obj = <W_TypeObject 'ellipsis' at 0xee1955ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee1955ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcea7b08>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee1955ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcea7b08>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcea7b08>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcea7b08>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_introspect_global_var_array _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf30a0d14>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_global_var_array'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_global_var_array'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_global_var_array'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_global_var_array'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_global_var_array'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_global_var_array'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_global_var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee157694> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedb3a90c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedb3a90c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_global_var_array'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_global_var_array'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xedb3a86c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedb3a86c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedb3a86c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xedb3a86c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee2797ec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee881e8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef59524c>, <W_TypeObject 'MemoryError' at 0xed891f8c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xedd7fa2c>, <W_TypeObject 'cinstancemethod' at 0xee1f70ac>, <W_TypeObject 'AttributeError' at 0xedda382c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedd88c4c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedd88c4c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedd88c4c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedd88c4c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc6ed40>> w_obj = <W_TypeObject 'ellipsis' at 0xedd88c4c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedd88c4c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc6ed40>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedd88c4c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc6ed40>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc6ed40>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc6ed40>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_introspect_integer_const _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf39c1e64>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_integer_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_integer_const'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_integer_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_integer_const'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_integer_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_integer_const'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_integer_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee780d4c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...eger_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee474d0c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee474d0c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...eger_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_integer_const'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_integer_const'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee474cec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee474cec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee474cec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee474cec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee79cb0c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee22990c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee22986c>, <W_TypeObject 'MemoryError' at 0xee3c11ac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee98114c>, <W_TypeObject 'cinstancemethod' at 0xeeaf3bcc>, <W_TypeObject 'AttributeError' at 0xef3b4bcc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee62a8cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee62a8cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee62a8cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee62a8cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbceacb0>> w_obj = <W_TypeObject 'ellipsis' at 0xee62a8cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee62a8cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbceacb0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee62a8cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbceacb0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbceacb0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xbceacb0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_introspect_typedef __________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf190fed4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_typedef'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_typedef'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_typedef'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xeddbd93c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ct_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee3e77ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee3e77ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ct_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_typedef'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee3e7d4c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee3e7d4c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee3e7d4c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee3e7d4c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xed97714c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee98616c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee98694c>, <W_TypeObject 'MemoryError' at 0xee61e74c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xedfb076c>, <W_TypeObject 'cinstancemethod' at 0xeebbbbcc>, <W_TypeObject 'AttributeError' at 0xee4593ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee56d96c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee56d96c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee56d96c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee56d96c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8da988>> w_obj = <W_TypeObject 'ellipsis' at 0xee56d96c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee56d96c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8da988>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee56d96c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8da988>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8da988>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc8da988>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_introspect_typedef_multiple _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf18df064>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_typedef_multiple'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_typedef_multiple'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_typedef_multiple'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_typedef_multiple'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_typedef_multiple'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_typedef_multiple'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_typedef_multiple'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee26c70c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_multiple'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee868ccc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee868ccc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...f_multiple'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_typedef_multiple'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_typedef_multiple'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee8684cc> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee8684cc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee8684cc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee8684cc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeea67b8c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee3b894c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee3b81ec>, <W_TypeObject 'MemoryError' at 0xee084fcc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xedf8876c>, <W_TypeObject 'cinstancemethod' at 0xedad282c>, <W_TypeObject 'AttributeError' at 0xedf709ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedc2eeac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedc2eeac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedc2eeac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedc2eeac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc792bb8>> w_obj = <W_TypeObject 'ellipsis' at 0xedc2eeac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedc2eeac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc792bb8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedc2eeac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc792bb8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc792bb8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc792bb8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __________ ERROR at setup of AppTestRecompiler.test_introspect_struct __________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf34566f4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_struct'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_struct'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_struct'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee1578c4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ect_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedce9d6c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedce9d6c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ect_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_struct'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xedce966c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedce966c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedce966c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xedce966c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xedbaf3ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xede4566c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xede455ac>, <W_TypeObject 'MemoryError' at 0xee5d864c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee064bcc>, <W_TypeObject 'cinstancemethod' at 0xede4572c>, <W_TypeObject 'AttributeError' at 0xee7d226c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedebb5ec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedebb5ec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedebb5ec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedebb5ec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd4cc70>> w_obj = <W_TypeObject 'ellipsis' at 0xedebb5ec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedebb5ec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd4cc70>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedebb5ec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd4cc70>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd4cc70>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd4cc70>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __________ ERROR at setup of AppTestRecompiler.test_introspect_union ___________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3ceaf7c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_union'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_union'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_union'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedf9aaa4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...pect_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee44dc6c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee44dc6c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...pect_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_union'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee44dcac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee44dcac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee44dcac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee44dcac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef0aed2c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xedc650cc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xedc6542c>, <W_TypeObject 'MemoryError' at 0xee4d176c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeed2698c>, <W_TypeObject 'cinstancemethod' at 0xee4f5ccc>, <W_TypeObject 'AttributeError' at 0xee2dfb0c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedcba82c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedcba82c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedcba82c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedcba82c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca41de8>> w_obj = <W_TypeObject 'ellipsis' at 0xedcba82c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedcba82c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca41de8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedcba82c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca41de8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca41de8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca41de8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____ ERROR at setup of AppTestRecompiler.test_introspect_struct_and_typedef ____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1ca610c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_struct_and_typedef'>...call__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_struct_and_typedef'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_struct_and_typedef'>...call__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_struct_and_typedef'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_struct_and_typedef'>...call__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_struct_and_typedef'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_struct_and_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee1ef734> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nd_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeff3fac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeeff3fac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...nd_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_struct_and_typedef'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_struct_and_typedef'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xeeff3f4c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeff3f4c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xeeff3f4c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xeeff3f4c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xef9d0a0c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee01470c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee0142ec>, <W_TypeObject 'MemoryError' at 0xeec3228c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee8a692c>, <W_TypeObject 'cinstancemethod' at 0xede5f32c>, <W_TypeObject 'AttributeError' at 0xed9798ec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee24946c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee24946c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee24946c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee24946c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc644a28>> w_obj = <W_TypeObject 'ellipsis' at 0xee24946c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee24946c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc644a28>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee24946c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc644a28>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc644a28>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc644a28>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______ ERROR at setup of AppTestRecompiler.test_introspect_included_type _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf313710c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_included_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_included_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_included_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_included_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_included_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_included_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, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_included_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee6393c4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...luded_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee908e2c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee908e2c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...luded_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_included_type'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_included_type'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee1fdeec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee1fdeec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee1fdeec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee1fdeec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee7dcd6c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeda9522c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeda9568c>, <W_TypeObject 'MemoryError' at 0xee545d6c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee68b6ec>, <W_TypeObject 'cinstancemethod' at 0xeda9524c>, <W_TypeObject 'AttributeError' at 0xee09b78c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee461e6c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee461e6c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee461e6c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee461e6c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc825618>> w_obj = <W_TypeObject 'ellipsis' at 0xee461e6c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee461e6c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc825618>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee461e6c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc825618>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc825618>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc825618>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __________ ERROR at setup of AppTestRecompiler.test_introspect_order ___________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf2ca8684>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_order'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_order'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_order'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_order'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_order'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_introspect_order'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_order'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedb328c4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...pect_order'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xed82ec6c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xed82ec6c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...pect_order'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_introspect_order'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_introspect_order'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xed82ec4c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xed82ec4c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xed82ec4c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xed82ec4c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeda4deec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xedaf5c4c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xedaf5c6c>, <W_TypeObject 'MemoryError' at 0xedd1294c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef4afb2c>, <W_TypeObject 'cinstancemethod' at 0xedc414cc>, <W_TypeObject 'AttributeError' at 0xedd2908c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee3b838c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee3b838c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee3b838c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee3b838c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc0b4770>> w_obj = <W_TypeObject 'ellipsis' at 0xee3b838c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee3b838c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc0b4770>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee3b838c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc0b4770>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc0b4770>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc0b4770>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_FFIFunctionWrapper __________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf1aef4c4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_FFIFunctionWrapper'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FFIFunctionWrapper'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_FFIFunctionWrapper'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FFIFunctionWrapper'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_FFIFunctionWrapper'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FFIFunctionWrapper'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_FFIFunctionWrapper'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedc2ad9c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ionWrapper'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee327cac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee327cac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ionWrapper'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_FFIFunctionWrapper'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_FFIFunctionWrapper'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee32738c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee32738c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee32738c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee32738c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee52e94c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee5cdb8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee5cd46c>, <W_TypeObject 'MemoryError' at 0xedeb002c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeddb784c>, <W_TypeObject 'cinstancemethod' at 0xee5cd50c>, <W_TypeObject 'AttributeError' at 0xedfcba2c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5774cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5774cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5774cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee5774cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcef37f0>> w_obj = <W_TypeObject 'ellipsis' at 0xee5774cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee5774cc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcef37f0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee5774cc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcef37f0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcef37f0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcef37f0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___ ERROR at setup of AppTestRecompiler.test_function_returns_float_complex ____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf299a4c4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_returns_float_complex'...all__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_returns_float_complex'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_returns_float_complex'...all__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_returns_float_complex'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_returns_float_complex'...all__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_returns_float_complex'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_returns_float_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee876edc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...at_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef0ae02c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef0ae02c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...at_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_returns_float_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_returns_float_complex'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef0aee6c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef0aee6c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef0aee6c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef0aee6c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xede5b10c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef19df6c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeeb7c52c>, <W_TypeObject 'MemoryError' at 0xedaf54ec>, <W_TypeObject 'bytearray' at 0xe...or' at 0xedbc906c>, <W_TypeObject 'cinstancemethod' at 0xedbaf3ac>, <W_TypeObject 'AttributeError' at 0xedbcad0c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee146dac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee146dac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee146dac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee146dac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca3ab60>> w_obj = <W_TypeObject 'ellipsis' at 0xee146dac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee146dac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca3ab60>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee146dac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca3ab60>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca3ab60>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca3ab60>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___ ERROR at setup of AppTestRecompiler.test_function_returns_double_complex ___ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xedfa61ec>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_returns_double_complex...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_returns_double_complex'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_returns_double_complex...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_returns_double_complex'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_returns_double_complex...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_returns_double_complex'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_returns_double_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee45ac34> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...le_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef79032c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xef79032c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...le_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_returns_double_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_returns_double_complex'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee9cbecc> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee9cbecc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee9cbecc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee9cbecc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee068dec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xedd485ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xedd48a6c>, <W_TypeObject 'MemoryError' at 0xee3220ac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xedbf616c>, <W_TypeObject 'cinstancemethod' at 0xedd4854c>, <W_TypeObject 'AttributeError' at 0xee76330c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee00be2c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee00be2c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee00be2c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee00be2c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb720048>> w_obj = <W_TypeObject 'ellipsis' at 0xee00be2c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee00be2c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb720048>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee00be2c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb720048>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb720048>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb720048>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___ ERROR at setup of AppTestRecompiler.test_function_argument_float_complex ___ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed9b89cc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_argument_float_complex...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_argument_float_complex'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_argument_float_complex...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_argument_float_complex'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_argument_float_complex...ll__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_argument_float_complex'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_argument_float_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xed96648c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...at_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeee72ecc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xeee72ecc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...at_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_argument_float_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_argument_float_complex'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef31b06c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef31b06c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef31b06c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef31b06c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xede4174c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xed809f4c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xed809cac>, <W_TypeObject 'MemoryError' at 0xedc05dcc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xed8be56c>, <W_TypeObject 'cinstancemethod' at 0xedd057ac>, <W_TypeObject 'AttributeError' at 0xee7285cc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee64c0ec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee64c0ec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee64c0ec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee64c0ec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcfdf438>> w_obj = <W_TypeObject 'ellipsis' at 0xee64c0ec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee64c0ec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcfdf438>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee64c0ec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcfdf438>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcfdf438>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcfdf438>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __ ERROR at setup of AppTestRecompiler.test_function_argument_double_complex ___ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf14f2e64>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_argument_double_comple...l__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_argument_double_complex'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_argument_double_comple...l__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_argument_double_complex'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_argument_double_comple...l__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_argument_double_complex'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_argument_double_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xed5fdd9c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...le_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee2e57cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee2e57cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...le_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_function_argument_double_complex'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_argument_double_complex'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee2e5cac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee2e5cac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee2e5cac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee2e5cac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xed8e810c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef80386c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xedfab5ac>, <W_TypeObject 'MemoryError' at 0xedb408ac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xedebcd6c>, <W_TypeObject 'cinstancemethod' at 0xede4c4ec>, <W_TypeObject 'AttributeError' at 0xed8d814c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeda1afec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeda1afec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeda1afec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeda1afec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb7604e8>> w_obj = <W_TypeObject 'ellipsis' at 0xeda1afec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeda1afec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb7604e8>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeda1afec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb7604e8>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb7604e8>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb7604e8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _______ ERROR at setup of AppTestRecompiler.test_typedef_array_dotdotdot _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xedba47d4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_typedef_array_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_typedef_array_dotdotdot'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_typedef_array_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_typedef_array_dotdotdot'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_typedef_array_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_typedef_array_dotdotdot'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_typedef_array_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee4e52fc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedab890c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedab890c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_typedef_array_dotdotdot'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_typedef_array_dotdotdot'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xedab89ac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedab89ac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedab89ac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xedab89ac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xeefeeb6c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xed940bec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xed940c2c>, <W_TypeObject 'MemoryError' at 0xeee4130c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xedfa21ec>, <W_TypeObject 'cinstancemethod' at 0xed9407ac>, <W_TypeObject 'AttributeError' at 0xee83a82c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeedddaec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeedddaec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeedddaec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeedddaec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd9e8b0>> w_obj = <W_TypeObject 'ellipsis' at 0xeedddaec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeedddaec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd9e8b0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeedddaec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd9e8b0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd9e8b0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd9e8b0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_call_with_custom_field_pos ______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xedc6a534>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_custom_field_pos'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_custom_field_pos'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_custom_field_pos'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_custom_field_pos'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_custom_field_pos'>, '...lticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_custom_field_pos'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_custom_field_pos'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedc243ec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._field_pos'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee1ce26c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee1ce26c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._field_pos'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_custom_field_pos'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_with_custom_field_pos'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee1cea2c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee1cea2c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee1cea2c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee1cea2c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xedba858c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeda453ec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeda450cc>, <W_TypeObject 'MemoryError' at 0xedc20fcc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xedead40c>, <W_TypeObject 'cinstancemethod' at 0xeda45a0c>, <W_TypeObject 'AttributeError' at 0xee809aac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed9dca8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed9dca8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed9dca8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed9dca8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc21c30>> w_obj = <W_TypeObject 'ellipsis' at 0xed9dca8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xed9dca8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc21c30>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xed9dca8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc21c30>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc21c30>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc21c30>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __ ERROR at setup of AppTestRecompiler.test_call_with_nested_anonymous_struct __ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed76b6f4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_nested_anonymous_stru...__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_nested_anonymous_struct'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_nested_anonymous_stru...__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_nested_anonymous_struct'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_nested_anonymous_stru...__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_nested_anonymous_struct'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_nested_anonymous_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xed748054> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ous_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee11c4cc> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee11c4cc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ous_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_nested_anonymous_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_with_nested_anonymous_struct'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee11c48c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee11c48c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee11c48c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee11c48c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee3e436c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee5d4dcc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xef1ea0ac>, <W_TypeObject 'MemoryError' at 0xed55432c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xed68c6ec>, <W_TypeObject 'cinstancemethod' at 0xeda6d56c>, <W_TypeObject 'AttributeError' at 0xee3132ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee26658c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee26658c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee26658c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee26658c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca82c78>> w_obj = <W_TypeObject 'ellipsis' at 0xee26658c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee26658c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca82c78>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee26658c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca82c78>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca82c78>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xca82c78>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _________ ERROR at setup of AppTestRecompiler.test_call_with_bitfield __________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed98c48c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_bitfield'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_bitfield'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_bitfield'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_bitfield'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_bitfield'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_bitfield'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_bitfield'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedb3207c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...h_bitfield'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee48386c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee48386c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...h_bitfield'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_bitfield'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_with_bitfield'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xef25fb0c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef25fb0c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xef25fb0c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xef25fb0c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xed7d860c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xedd05a4c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xedd0568c>, <W_TypeObject 'MemoryError' at 0xee1f57cc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeeb95c0c>, <W_TypeObject 'cinstancemethod' at 0xee21292c>, <W_TypeObject 'AttributeError' at 0xed906d2c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedeb00ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedeb00ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedeb00ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedeb00ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd57260>> w_obj = <W_TypeObject 'ellipsis' at 0xedeb00ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedeb00ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd57260>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedeb00ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd57260>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd57260>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcd57260>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_call_with_zero_length_field _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xedcb7ca4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_zero_length_field'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_zero_length_field'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_zero_length_field'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_zero_length_field'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_zero_length_field'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_zero_length_field'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_zero_length_field'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedc97554> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ngth_field'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xed7a1a0c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xed7a1a0c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ngth_field'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_zero_length_field'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_with_zero_length_field'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xed7a1aac> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xed7a1aac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xed7a1aac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xed7a1aac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xedca644c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee83a82c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xee83a8ec>, <W_TypeObject 'MemoryError' at 0xedb6fcac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee06882c>, <W_TypeObject 'cinstancemethod' at 0xedd5aaac>, <W_TypeObject 'AttributeError' at 0xed5445cc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedc9572c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedc9572c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedc9572c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedc9572c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcdb34e0>> w_obj = <W_TypeObject 'ellipsis' at 0xedc9572c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedc9572c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcdb34e0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedc9572c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcdb34e0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcdb34e0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcdb34e0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ___________ ERROR at setup of AppTestRecompiler.test_call_with_union ___________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed7c53ac>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_union'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_union'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_union'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xed77cd24> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...with_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee01114c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee01114c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...with_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_union'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_with_union'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee011b0c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee011b0c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee011b0c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee011b0c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee3ca26c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xef70c44c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xedeb5eac>, <W_TypeObject 'MemoryError' at 0xedf7b76c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xed91deac>, <W_TypeObject 'cinstancemethod' at 0xedd333ec>, <W_TypeObject 'AttributeError' at 0xedf1d92c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed99db2c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed99db2c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed99db2c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed99db2c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc76b20>> w_obj = <W_TypeObject 'ellipsis' at 0xed99db2c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xed99db2c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc76b20>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xed99db2c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc76b20>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc76b20>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcc76b20>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _______ ERROR at setup of AppTestRecompiler.test_call_with_packed_struct _______ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed9fe144>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_packed_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_packed_struct'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_packed_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_packed_struct'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_packed_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_with_packed_struct'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_packed_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedea2144> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ked_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedc5d8ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedc5d8ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ked_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_with_packed_struct'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_with_packed_struct'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xedc5da0c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedc5da0c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedc5da0c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xedc5da0c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xed563ccc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xed570b0c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xed57040c>, <W_TypeObject 'MemoryError' at 0xed9cc66c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xed451dcc>, <W_TypeObject 'cinstancemethod' at 0xed5709cc>, <W_TypeObject 'AttributeError' at 0xed6d1acc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeda4e5ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeda4e5ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeda4e5ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeda4e5ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc882450>> w_obj = <W_TypeObject 'ellipsis' at 0xeda4e5ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeda4e5ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc882450>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeda4e5ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc882450>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc882450>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc882450>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_gcc_visibility_hidden ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed7ca924>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_gcc_visibility_hidden'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_gcc_visibility_hidden'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_gcc_visibility_hidden'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_gcc_visibility_hidden'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_gcc_visibility_hidden'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_gcc_visibility_hidden'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_gcc_visibility_hidden'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xed83898c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ity_hidden'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee7dd70c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xee7dd70c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ity_hidden'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_gcc_visibility_hidden'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_gcc_visibility_hidden'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xee3e284c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee3e284c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xee3e284c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xee3e284c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xed8e864c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xedd19eac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xedd199cc>, <W_TypeObject 'MemoryError' at 0xee95d50c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xef46694c>, <W_TypeObject 'cinstancemethod' at 0xedd1982c>, <W_TypeObject 'AttributeError' at 0xee68bc8c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeed179ec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeed179ec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeed179ec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xeed179ec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcefc768>> w_obj = <W_TypeObject 'ellipsis' at 0xeed179ec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xeed179ec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcefc768>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xeed179ec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcefc768>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcefc768>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcefc768>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____ ERROR at setup of AppTestRecompiler.test_override_default_definition _____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed87f144>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_override_default_definition'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_override_default_definition'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_override_default_definition'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_override_default_definition'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_override_default_definition'>, ...ticall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_override_default_definition'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_override_default_definition'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xed6bb11c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...definition'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedab07ec> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedab07ec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...definition'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_override_default_definition'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_override_default_definition'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xedab090c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedab090c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedab090c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xedab090c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xedf404ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeda07e2c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeda079cc>, <W_TypeObject 'MemoryError' at 0xee1bc46c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee986f2c>, <W_TypeObject 'cinstancemethod' at 0xeda07b0c>, <W_TypeObject 'AttributeError' at 0xedbf666c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed75efac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed75efac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed75efac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed75efac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xd092fe0>> w_obj = <W_TypeObject 'ellipsis' at 0xed75efac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xed75efac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xd092fe0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xed75efac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xd092fe0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xd092fe0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xd092fe0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_char16_char32_plain_c ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed90f144>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_char16_char32_plain_c'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_char16_char32_plain_c'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_char16_char32_plain_c'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_char16_char32_plain_c'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_char16_char32_plain_c'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_char16_char32_plain_c'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_char16_char32_plain_c'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xed88289c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...32_plain_c'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xed7a170c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xed7a170c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...32_plain_c'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_char16_char32_plain_c'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_char16_char32_plain_c'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xed7a10ec> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xed7a10ec> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xed7a10ec> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xed7a10ec> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee52e82c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xeda565cc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xeda5690c>, <W_TypeObject 'MemoryError' at 0xed8d104c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xedfe1d0c>, <W_TypeObject 'cinstancemethod' at 0xede930cc>, <W_TypeObject 'AttributeError' at 0xee01f72c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee3af2ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee3af2ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee3af2ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xee3af2ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb720218>> w_obj = <W_TypeObject 'ellipsis' at 0xee3af2ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xee3af2ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb720218>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xee3af2ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb720218>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb720218>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xb720218>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____________ ERROR at setup of AppTestRecompiler.test_loader_spec _____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed7cf684>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_loader_spec'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_loader_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_loader_spec'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_loader_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_loader_spec'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_loader_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, 5 meths, kwargs={'item': <AppTestMethod 'test_loader_spec'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xede2d2ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...oader_spec'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xed1bfd4c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xed1bfd4c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...oader_spec'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_loader_spec'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_loader_spec'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xed1bfa2c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xed1bfa2c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xed1bfa2c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xed1bfa2c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee1f51cc> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xed6bcdcc> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xed6bce6c>, <W_TypeObject 'MemoryError' at 0xee44d6cc>, <W_TypeObject 'bytearray' at 0xe...or' at 0xefc16fac>, <W_TypeObject 'cinstancemethod' at 0xedf481ac>, <W_TypeObject 'AttributeError' at 0xed8e8cec>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedafa74c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedafa74c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedafa74c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedafa74c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcad6420>> w_obj = <W_TypeObject 'ellipsis' at 0xedafa74c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedafa74c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcad6420>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedafa74c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcad6420>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcad6420>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcad6420>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _______________ ERROR at setup of AppTestRecompiler.test_release _______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed5391b4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_release'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_release'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_release'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_release'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_release'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_release'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_release'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xee2a7b94> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...st_release'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xed874f2c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xed874f2c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...st_release'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_release'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xed874c6c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xed874c6c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xed874c6c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xed874c6c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xed6d4cec> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xed7ed90c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xed7ed7ec>, <W_TypeObject 'MemoryError' at 0xee03fd0c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee3f4e6c>, <W_TypeObject 'cinstancemethod' at 0xed7ed98c>, <W_TypeObject 'AttributeError' at 0xed53548c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed53fe8c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed53fe8c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed53fe8c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed53fe8c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc233b68>> w_obj = <W_TypeObject 'ellipsis' at 0xed53fe8c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xed53fe8c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc233b68>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xed53fe8c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc233b68>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc233b68>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc233b68>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestRecompiler.test_release_new_allocator ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xedc2d10c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_release_new_allocator'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_release_new_allocator'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_release_new_allocator'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_release_new_allocator'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_release_new_allocator'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_release_new_allocator'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_release_new_allocator'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xed79ac5c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._allocator'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedd1938c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedd1938c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._allocator'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_release_new_allocator'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_new_allocator'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xedd19dcc> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedd19dcc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedd19dcc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xedd19dcc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xefa0760c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xee7425ec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xed854dec>, <W_TypeObject 'MemoryError' at 0xef803b6c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xeda0296c>, <W_TypeObject 'cinstancemethod' at 0xed57fbcc>, <W_TypeObject 'AttributeError' at 0xef35af6c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed808d0c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed808d0c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed808d0c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed808d0c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb8c150>> w_obj = <W_TypeObject 'ellipsis' at 0xed808d0c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xed808d0c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb8c150>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xed808d0c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb8c150>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb8c150>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcb8c150>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int __ ERROR at setup of AppTestRecompiler.test_struct_with_func_with_struct_arg ___ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed9314fc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_with_func_with_struct_ar...l__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_struct_with_func_with_struct_arg'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_with_func_with_struct_ar...l__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_struct_with_func_with_struct_arg'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_with_func_with_struct_ar...l__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_struct_with_func_with_struct_arg'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_with_func_with_struct_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xedc7a554> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...struct_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedbb894c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xedbb894c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...struct_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_struct_with_func_with_struct_arg'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_struct_with_func_with_struct_arg'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xedbb882c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedbb882c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xedbb882c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xedbb882c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xedc0d16c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xed781a6c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xed7814ac>, <W_TypeObject 'MemoryError' at 0xed6bcdac>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee8097ec>, <W_TypeObject 'cinstancemethod' at 0xedfa230c>, <W_TypeObject 'AttributeError' at 0xed57394c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedb400ac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedb400ac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedb400ac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xedb400ac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc950398>> w_obj = <W_TypeObject 'ellipsis' at 0xedb400ac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xedb400ac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc950398>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xedb400ac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc950398>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc950398>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xc950398>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ____ ERROR at setup of AppTestRecompiler.test_call_function_offset_in_bytes ____ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xed72bd14>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_function_offset_in_bytes'>...call__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_function_offset_in_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 0xf79cb32c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_function_offset_in_bytes'>...call__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_function_offset_in_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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf6966bac>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf759a78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7581c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_function_offset_in_bytes'>...call__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_function_offset_in_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, 5 meths, kwargs={'item': <AppTestMethod 'test_call_function_offset_in_bytes'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xed7201e4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_in_bytes'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefbab56c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xefbab56c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_in_bytes'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_call_function_offset_in_bytes'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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_function_offset_in_bytes'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'usemodules': ['_cffi_backend', 'imp', 'cpyext', 'struct']} config = <rpython.config.config.Config object at 0xefbab86c> key = (((False, True, False, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefbab86c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xefbab86c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xefbab86c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xee3c14ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xed42828c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xeff4a3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xeff4a480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xed42830c>, <W_TypeObject 'MemoryError' at 0xed66a72c>, <W_TypeObject 'bytearray' at 0xe...or' at 0xee7b974c>, <W_TypeObject 'cinstancemethod' at 0xed42820c>, <W_TypeObject 'AttributeError' at 0xee82accc>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed5c6fcc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed5c6fcc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed5c6fcc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xed5c6fcc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcf7ef98>> w_obj = <W_TypeObject 'ellipsis' at 0xed5c6fcc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xed5c6fcc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcf7ef98>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xed5c6fcc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcf7ef98>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcf7ef98>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xcf7ef98>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ============= 335 passed, 9 skipped, 124 error in 3471.39 seconds ============== ++ 03:35:10 starting module/cpyext/test/test_async_iter.py [47 started in total] __ module/cpyext/test/test_api.py [44 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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 4 items module/cpyext/test/test_api.py EE.. ==================================== ERRORS ==================================== ______________ ERROR at setup of TestConversion.test_conversions _______________ item = <Function 'test_conversions'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tool/pytest/objspace.py:24: in gettestobjspace space = maketestobjspace(config) tool/pytest/objspace.py:34: in maketestobjspace space = make_objspace(config) tool/option.py:33: in make_objspace return StdObjSpace(config) interpreter/baseobjspace.py:481: in __init__ self.initialize() objspace/std/objspace.py:118: in initialize self.setup_builtin_modules() interpreter/baseobjspace.py:739: in setup_builtin_modules self.fromcache(State).build_api() module/cpyext/state.py:128: in build_api self.api_lib = str(api.build_bridge(self.space)) module/cpyext/api.py:1468: in build_bridge builder.attach_all(space) module/cpyext/api.py:1535: in attach_all attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1497: in attach_recursively make_ref(space, w_type)) module/cpyext/pyobject.py:510: in make_ref return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:483: in get_pyobj_and_incref pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: in as_pyobj py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:326: in create_ref track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:375: in track_reference w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:132: in _cpyext_attach_pyobj rawrefcount.create_link_pypy(self, py_obj) ../rpython/rlib/rawrefcount.py:187: in create_link_pypy assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:102: in _ob_link_get return ob.c_ob_pypy_link _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8c79c10>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________________ ERROR at setup of TestConversion.test_typedef _________________ item = <Function 'test_typedef'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tool/pytest/objspace.py:24: in gettestobjspace space = maketestobjspace(config) tool/pytest/objspace.py:34: in maketestobjspace space = make_objspace(config) tool/option.py:33: in make_objspace return StdObjSpace(config) interpreter/baseobjspace.py:481: in __init__ self.initialize() objspace/std/objspace.py:118: in initialize self.setup_builtin_modules() interpreter/baseobjspace.py:739: in setup_builtin_modules self.fromcache(State).build_api() module/cpyext/state.py:128: in build_api self.api_lib = str(api.build_bridge(self.space)) module/cpyext/api.py:1468: in build_bridge builder.attach_all(space) module/cpyext/api.py:1535: in attach_all attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1497: in attach_recursively make_ref(space, w_type)) module/cpyext/pyobject.py:510: in make_ref return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:483: in get_pyobj_and_incref pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: in as_pyobj py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:326: in create_ref track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:375: in track_reference w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:132: in _cpyext_attach_pyobj rawrefcount.create_link_pypy(self, py_obj) ../rpython/rlib/rawrefcount.py:187: in create_link_pypy assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:102: in _ob_link_get return ob.c_ob_pypy_link _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8dc9bf8>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ====================== 2 passed, 2 error in 43.04 seconds ====================== ++ 03:36:08 starting module/cpyext/test/test_boolobject.py [48 started in total] __ module/cpyext/test/test_async_iter.py [45 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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 3 items module/cpyext/test/test_async_iter.py EEE ==================================== ERRORS ==================================== _______________ ERROR at setup of AppTestAsyncIter.test_asyncgen _______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf42d95dc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_asyncgen'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_asyncgen'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf7a8932c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf433c4ec>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf765978c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf763fc4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_asyncgen'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_asyncgen'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf433c4ec>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf765978c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf763fc4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_asyncgen'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_asyncgen'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_asyncgen'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf42abacc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_asyncgen'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf42638ec> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf42638ec> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...t_asyncgen'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_asyncgen'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_asyncgen'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'objspace.disable_entrypoints_in_cffi': True, 'objspace.std.withspecialisedtuple': True, 'usemodules': ['cpyext', 'thread', 'struct', 'array', 'itertools', 'time', ...]} config = <rpython.config.config.Config object at 0xf426390c> key = (((False, True, True, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf426390c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf426390c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xf426390c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf4206f6c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xf41cdf4c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf419b020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xf419b3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf419b480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xf41cdfac>, <W_TypeObject 'MemoryError' at 0xf423550c>, <W_TypeObject 'bytearray' at 0xf...or' at 0xf4232e0c>, <W_TypeObject 'cinstancemethod' at 0xf41dd4ec>, <W_TypeObject 'AttributeError' at 0xf4248bac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d97dac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d97dac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d97dac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d97dac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9a783a0>> w_obj = <W_TypeObject 'ellipsis' at 0xf3d97dac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xf3d97dac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9a783a0>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xf3d97dac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9a783a0>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9a783a0>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9a783a0>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________ ERROR at setup of AppTestAsyncIter.test_async_gen_exception_04 ________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf38bc064>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_async_gen_exception_04'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_async_gen_exception_04'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf7a8932c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf433c4ec>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf765978c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf763fc4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_async_gen_exception_04'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_async_gen_exception_04'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf433c4ec>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf765978c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf763fc4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_async_gen_exception_04'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_async_gen_exception_04'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_async_gen_exception_04'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf3c88d9c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ception_04'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf3d92c6c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf3d92c6c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ception_04'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_async_gen_exception_04'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_async_gen_exception_04'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'objspace.disable_entrypoints_in_cffi': True, 'objspace.std.withspecialisedtuple': True, 'usemodules': ['cpyext', 'thread', 'struct', 'array', 'itertools', 'time', ...]} config = <rpython.config.config.Config object at 0xf3f254cc> key = (((False, True, True, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf3f254cc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf3f254cc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xf3f254cc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf3805c0c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xf39f3b6c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf419b020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xf419b3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf419b480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xf39f39ec>, <W_TypeObject 'MemoryError' at 0xf3dc3fcc>, <W_TypeObject 'bytearray' at 0xf...or' at 0xf3ad2acc>, <W_TypeObject 'cinstancemethod' at 0xf3a0194c>, <W_TypeObject 'AttributeError' at 0xf3adb90c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d06fac> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d06fac> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d06fac> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d06fac> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa013c48>> w_obj = <W_TypeObject 'ellipsis' at 0xf3d06fac> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xf3d06fac>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa013c48>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xf3d06fac> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa013c48>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa013c48>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xa013c48>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____________ ERROR at setup of AppTestAsyncIter.test_coro_retval ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf382795c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_coro_retval'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_coro_retval'>} def __call__(self, **kwargs): assert not self.is_historic() > return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) ../_pytest/vendored_packages/pluggy.py:724: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.config.PytestPluginManager object at 0xf7a8932c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf433c4ec>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf765978c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf763fc4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_coro_retval'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_coro_retval'>} def _hookexec(self, hook, methods, kwargs): # called from all hookcaller instances. # enable_tracing will set its own wrapping function at self._inner_hookexec > return self._inner_hookexec(hook, methods, kwargs) ../_pytest/vendored_packages/pluggy.py:338: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf433c4ec>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf765978c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf763fc4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_coro_retval'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_coro_retval'>} self._inner_hookexec = lambda hook, methods, kwargs: \ > _MultiCall(methods, kwargs, hook.spec_opts).execute() ../_pytest/vendored_packages/pluggy.py:333: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_coro_retval'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf3d1a464> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...oro_retval'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf38cb1ac> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf38cb1ac> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...oro_retval'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_coro_retval'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: return _wrapped_call(hook_impl.function(*args), self.execute) > res = hook_impl.function(*args) ../_pytest/vendored_packages/pluggy.py:596: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ item = <AppTestMethod 'test_coro_retval'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'objspace.disable_entrypoints_in_cffi': True, 'objspace.std.withspecialisedtuple': True, 'usemodules': ['cpyext', 'thread', 'struct', 'array', 'itertools', 'time', ...]} config = <rpython.config.config.Config object at 0xf38cb1cc> key = (((False, True, True, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf38cb1cc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf38cb1cc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xf38cb1cc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf380e46c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xf38730ac> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf419b020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xf419b3a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf419b480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xf387330c>, <W_TypeObject 'MemoryError' at 0xf37e984c>, <W_TypeObject 'bytearray' at 0xf...or' at 0xf420e0ec>, <W_TypeObject 'cinstancemethod' at 0xf387948c>, <W_TypeObject 'AttributeError' at 0xf420b48c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d3ed0c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d3ed0c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d3ed0c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d3ed0c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9b94190>> w_obj = <W_TypeObject 'ellipsis' at 0xf3d3ed0c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xf3d3ed0c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9b94190>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xf3d3ed0c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9b94190>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9b94190>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9b94190>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int =========================== 3 error in 60.19 seconds =========================== ++ 03:36:52 starting module/cpyext/test/test_borrow.py [49 started in total] __ module/cpyext/test/test_boolobject.py [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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 4 items module/cpyext/test/test_boolobject.py EEEE ==================================== ERRORS ==================================== ________________ ERROR at setup of TestBoolObject.test_fromlong ________________ item = <Function 'test_fromlong'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tool/pytest/objspace.py:24: in gettestobjspace space = maketestobjspace(config) tool/pytest/objspace.py:34: in maketestobjspace space = make_objspace(config) tool/option.py:33: in make_objspace return StdObjSpace(config) interpreter/baseobjspace.py:481: in __init__ self.initialize() objspace/std/objspace.py:118: in initialize self.setup_builtin_modules() interpreter/baseobjspace.py:739: in setup_builtin_modules self.fromcache(State).build_api() module/cpyext/state.py:128: in build_api self.api_lib = str(api.build_bridge(self.space)) module/cpyext/api.py:1468: in build_bridge builder.attach_all(space) module/cpyext/api.py:1535: in attach_all attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1497: in attach_recursively make_ref(space, w_type)) module/cpyext/pyobject.py:510: in make_ref return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:483: in get_pyobj_and_incref pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: in as_pyobj py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:326: in create_ref track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:375: in track_reference w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:132: in _cpyext_attach_pyobj rawrefcount.create_link_pypy(self, py_obj) ../rpython/rlib/rawrefcount.py:187: in create_link_pypy assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:102: in _ob_link_get return ob.c_ob_pypy_link _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9251250>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _______________ ERROR at setup of AppTestBoolMacros.test_macros ________________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3cde4c4>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macros'>, '__multicall__': <_MultiCall 0 results, 5 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 0xf7a2332c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf42d71cc>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf75f378c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf75d9c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macros'>, '__multicall__': <_MultiCall 0 results, 5 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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf42d71cc>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf75f378c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf75d9c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macros'>, '__multicall__': <_MultiCall 0 results, 5 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, 5 meths, kwargs={'item': <AppTestMethod 'test_macros'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf3bf025c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...est_macros'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf3ed226c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf3ed226c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...est_macros'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_macros'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'objspace.disable_entrypoints_in_cffi': True, 'objspace.std.withspecialisedtuple': True, 'usemodules': ['cpyext', 'thread', 'struct', 'array', 'itertools', 'time', ...]} config = <rpython.config.config.Config object at 0xf3ed222c> key = (((False, True, True, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf3ed222c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf3ed222c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xf3ed222c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf38aa4ac> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xf38b7a4c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4135020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xf41353a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4135480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xf38b782c>, <W_TypeObject 'MemoryError' at 0xf3b2e96c>, <W_TypeObject 'bytearray' at 0xf...or' at 0xf3ce662c>, <W_TypeObject 'cinstancemethod' at 0xf3d0d24c>, <W_TypeObject 'AttributeError' at 0xf3cc618c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf387694c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf387694c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf387694c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf387694c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9133270>> w_obj = <W_TypeObject 'ellipsis' at 0xf387694c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xf387694c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9133270>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xf387694c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9133270>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9133270>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x9133270>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________________ ERROR at setup of AppTestBoolMacros.test_toint ________________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3c0d144>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_toint'>, '__multicall__': <_MultiCall 0 results, 5 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 0xf7a2332c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf42d71cc>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf75f378c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf75d9c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_toint'>, '__multicall__': <_MultiCall 0 results, 5 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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf42d71cc>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf75f378c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf75d9c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_toint'>, '__multicall__': <_MultiCall 0 results, 5 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, 5 meths, kwargs={'item': <AppTestMethod 'test_toint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf3bede3c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...test_toint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf3af716c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf3af716c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...test_toint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_toint'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'objspace.disable_entrypoints_in_cffi': True, 'objspace.std.withspecialisedtuple': True, 'usemodules': ['cpyext', 'thread', 'struct', 'array', 'itertools', 'time', ...]} config = <rpython.config.config.Config object at 0xf3af70ac> key = (((False, True, True, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf3af70ac> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf3af70ac> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xf3af70ac> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf394bc2c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xf3956e8c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4135020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xf41353a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4135480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xf395678c>, <W_TypeObject 'MemoryError' at 0xf3b1c9ac>, <W_TypeObject 'bytearray' at 0xf...or' at 0xf41b0b2c>, <W_TypeObject 'cinstancemethod' at 0xf3a50dec>, <W_TypeObject 'AttributeError' at 0xf397e3ac>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3a4d3ec> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3a4d3ec> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3a4d3ec> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3a4d3ec> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x924e038>> w_obj = <W_TypeObject 'ellipsis' at 0xf3a4d3ec> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xf3a4d3ec>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x924e038>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xf3a4d3ec> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x924e038>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x924e038>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x924e038>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ________________ ERROR at setup of AppTestBoolMacros.test_check ________________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3ba2304>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_check'>, '__multicall__': <_MultiCall 0 results, 5 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 0xf7a2332c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf42d71cc>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf75f378c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf75d9c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_check'>, '__multicall__': <_MultiCall 0 results, 5 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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf42d71cc>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf75f378c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf75d9c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_check'>, '__multicall__': <_MultiCall 0 results, 5 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, 5 meths, kwargs={'item': <AppTestMethod 'test_check'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf3977b44> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...test_check'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf37ee84c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf37ee84c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...test_check'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_check'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'objspace.disable_entrypoints_in_cffi': True, 'objspace.std.withspecialisedtuple': True, 'usemodules': ['cpyext', 'thread', 'struct', 'array', 'itertools', 'time', ...]} config = <rpython.config.config.Config object at 0xf37ee88c> key = (((False, True, True, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf37ee88c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf37ee88c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xf37ee88c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf3aa7d8c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xf3487a4c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4135020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xf41353a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4135480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xf348746c>, <W_TypeObject 'MemoryError' at 0xf3c9c8ec>, <W_TypeObject 'bytearray' at 0xf...or' at 0xf3b828ec>, <W_TypeObject 'cinstancemethod' at 0xf39c29cc>, <W_TypeObject 'AttributeError' at 0xf3b9d26c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3b31f0c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3b31f0c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3b31f0c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3b31f0c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x91eb140>> w_obj = <W_TypeObject 'ellipsis' at 0xf3b31f0c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xf3b31f0c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x91eb140>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xf3b31f0c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x91eb140>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x91eb140>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x91eb140>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int =========================== 4 error in 78.68 seconds =========================== ++ 03:38:12 starting module/cpyext/test/test_buffer.py [50 started in total] __ module/cpyext/test/test_borrow.py [47 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/own-linux-x86-32/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/own-linux-x86-32/build/pytest.pyc rootdir: /build_dir/own-linux-x86-32/build, inifile: pytest.ini plugins: hypothesis-4.39.3 collected 3 items module/cpyext/test/test_borrow.py EEE ==================================== ERRORS ==================================== _____________ ERROR at setup of AppTestBorrow.test_tuple_borrowing _____________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf429e9cc>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_tuple_borrowing'>, '__multicall__': <_MultiCall 0 results, 5 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 0xf7a5032c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf430438c>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf761f78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7606c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_tuple_borrowing'>, '__multicall__': <_MultiCall 0 results, 5 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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf430438c>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf761f78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7606c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_tuple_borrowing'>, '__multicall__': <_MultiCall 0 results, 5 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, 5 meths, kwargs={'item': <AppTestMethod 'test_tuple_borrowing'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf4273af4> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._borrowing'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf423142c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf423142c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i..._borrowing'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_tuple_borrowing'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'objspace.disable_entrypoints_in_cffi': True, 'objspace.std.withspecialisedtuple': True, 'usemodules': ['cpyext', 'thread', 'struct', 'array', 'itertools', 'time', ...]} config = <rpython.config.config.Config object at 0xf423144c> key = (((False, True, True, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf423144c> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf423144c> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xf423144c> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf41d770c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xf41a464c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4162020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xf41623a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4162480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xf41a46cc>, <W_TypeObject 'MemoryError' at 0xf41fcb2c>, <W_TypeObject 'bytearray' at 0xf...or' at 0xf420b7cc>, <W_TypeObject 'cinstancemethod' at 0xf41a4c6c>, <W_TypeObject 'AttributeError' at 0xf421534c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d62ccc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d62ccc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d62ccc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3d62ccc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8c71918>> w_obj = <W_TypeObject 'ellipsis' at 0xf3d62ccc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xf3d62ccc>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8c71918>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xf3d62ccc> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8c71918>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8c71918>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8c71918>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int _____________ ERROR at setup of AppTestBorrow.test_borrow_destroy ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf3d1448c>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_borrow_destroy'>, '__multicall__': <_MultiCall 0 results, 5 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 0xf7a5032c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf430438c>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf761f78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7606c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_borrow_destroy'>, '__multicall__': <_MultiCall 0 results, 5 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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf430438c>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf761f78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7606c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_borrow_destroy'>, '__multicall__': <_MultiCall 0 results, 5 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, 5 meths, kwargs={'item': <AppTestMethod 'test_borrow_destroy'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf3d75edc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ow_destroy'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf3b1214c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf3b1214c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ow_destroy'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_borrow_destroy'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'objspace.disable_entrypoints_in_cffi': True, 'objspace.std.withspecialisedtuple': True, 'usemodules': ['cpyext', 'thread', 'struct', 'array', 'itertools', 'time', ...]} config = <rpython.config.config.Config object at 0xf3b120cc> key = (((False, True, True, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf3b120cc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf3b120cc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xf3b120cc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf38b6b2c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xf39c6a6c> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4162020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xf41623a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4162480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xf39c68ec>, <W_TypeObject 'MemoryError' at 0xf3d90e8c>, <W_TypeObject 'bytearray' at 0xf...or' at 0xf3aa1cac>, <W_TypeObject 'cinstancemethod' at 0xf39d188c>, <W_TypeObject 'AttributeError' at 0xf3aab82c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3872e6c> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3872e6c> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3872e6c> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3872e6c> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8d32c18>> w_obj = <W_TypeObject 'ellipsis' at 0xf3872e6c> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <W_TypeObject 'ellipsis' at 0xf3872e6c>, space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8d32c18>> def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj > rawrefcount.create_link_pypy(self, py_obj) module/cpyext/pyobject.py:132: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ p = <W_TypeObject 'ellipsis' at 0xf3872e6c> ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8d32c18>> @not_rpython def create_link_pypy(p, ob): "a link where the PyPy object contains some or all the data" #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob) assert p not in _pypy2ob assert ob._obj not in _pypy2ob_rev > assert not _ob_link_get(ob) ../rpython/rlib/rawrefcount.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8d32c18>> def _ob_link_get(ob): > return ob.c_ob_pypy_link ../rpython/rlib/rawrefcount.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x8d32c18>> field_name = 'c_ob_pypy_link' def __getattr__(self, field_name): # ! can only return basic or ptr ! if isinstance(self._T, Struct): if field_name in self._T._flds: o = self._obj._getattr(field_name) return self._expose(field_name, o) try: return self._lookup_adtmeth(field_name) except AttributeError: raise AttributeError("%r instance has no field %r" % (self._T, > field_name)) E AttributeError: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link' ../rpython/rtyper/lltypesystem/lltype.py:1270: AttributeError ---------------------------- Captured stderr setup ----------------------------- [platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c: In function \u2018cpyexttestBytes_FromFormatV\u2019:\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:32: warning: format \u2018%zd\u2019 expects argument of type \u2018signed size_t\u2019, but argument 3 has type \u2018Py_ssize_t\u2019 {aka \u2018long int\u2019} [-Wformat=]\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ^~~\n[platform:WARNING] /build_dir/own-linux-x86-32/build/pypy/module/cpyext/src/bytesobject.c:135:54: note: format string is defined here\n[platform:WARNING] 135 | sprintf(s, "%" PY_FORMAT_SIZE_T "d",\n[platform:WARNING] | ~~~~~~~~~~~~~~~~~~~~~^\n[platform:WARNING] | |\n[platform:WARNING] | int ______________ ERROR at setup of AppTestBorrow.test_double_borrow ______________ self = <CallInfo when='setup' exception: <Struct _object { c_ob_refcnt, c_ob_type }> instance has no field 'c_ob_pypy_link'> func = <function <lambda> at 0xf41a7224>, when = 'setup' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=item, **kwds), when=when) ../_pytest/runner.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_HookCaller 'pytest_runtest_setup'> kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_double_borrow'>, '__multicall__': <_MultiCall 0 results, 5 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 0xf7a5032c> hook = <_HookCaller 'pytest_runtest_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf430438c>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf761f78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7606c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_double_borrow'>, '__multicall__': <_MultiCall 0 results, 5 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_setup'> methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0xf430438c>, <_pytest.vendored_packages.pluggy.HookImpl instan...d_packages.pluggy.HookImpl instance at 0xf761f78c>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0xf7606c4c>] kwargs = {'__multicall__': <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_double_borrow'>, '__multicall__': <_MultiCall 0 results, 5 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, 5 meths, kwargs={'item': <AppTestMethod 'test_double_borrow'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.hookwrapper: > return _wrapped_call(hook_impl.function(*args), self.execute) ../_pytest/vendored_packages/pluggy.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrap_controller = <generator object pytest_runtest_setup at 0xf42a41bc> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ble_borrow'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def _wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield exactly once. The yield point will trigger calling the wrapped function and return its _CallOutcome to the yield point. The generator then needs to finish (raise StopIteration) in order for the wrapped call to complete. """ try: next(wrap_controller) # first yield except StopIteration: _raise_wrapfail(wrap_controller, "did not yield") call_outcome = _CallOutcome(func) try: wrap_controller.send(call_outcome) _raise_wrapfail(wrap_controller, "has second yield") except StopIteration: pass > return call_outcome.get_result() ../_pytest/vendored_packages/pluggy.py:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf3b2418c> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xf3b2418c> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 5 meths, kwargs={'i...ble_borrow'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}>> def __init__(self, func): try: > self.result = func() ../_pytest/vendored_packages/pluggy.py:264: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_MultiCall 0 results, 5 meths, kwargs={'item': <AppTestMethod 'test_double_borrow'>, '__multicall__': <_MultiCall 0 results, 5 meths, kwargs={...}>}> def execute(self): all_kwargs = self.kwargs self.results = results = [] firstresult = self.specopts.get("firstresult") while self.hook_impls: hook_impl = self.hook_impls.pop() args = [all_kwargs[argname] for argname in hook_impl.argnames] if hook_impl.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'> @pytest.hookimpl(tryfirst=True) def pytest_runtest_setup(item): if isinstance(item, pytest.Function): config = item.config if get_marker(item, name='pypy_only'): if config.applevel is not None and not config.applevel.is_pypy: pytest.skip('PyPy-specific test') appclass = item.getparent(pytest.Class) if appclass is not None: from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) > appclass.obj.space = gettestobjspace(**spaceconfig) conftest.py:259: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ kwds = {'objspace.disable_entrypoints_in_cffi': True, 'objspace.std.withspecialisedtuple': True, 'usemodules': ['cpyext', 'thread', 'struct', 'array', 'itertools', 'time', ...]} config = <rpython.config.config.Config object at 0xf3b241cc> key = (((False, True, True, True, True, True, ...), True, None, False, None, False, ...), False, (False, 'lltype', 'c', False, True, 'ref', ...)) def gettestobjspace(**kwds): """ helper for instantiating and caching spaces for testing. """ try: config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) if getattr(option, 'runappdirect', None): return TinyObjSpace() key = config.getkey() try: return _SPACECACHE[key] except KeyError: > space = maketestobjspace(config) tool/pytest/objspace.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf3b241cc> def maketestobjspace(config=None): if config is None: config = make_config(option) if config.objspace.usemodules.thread: config.translation.thread = True config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest' > space = make_objspace(config) tool/pytest/objspace.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ config = <rpython.config.config.Config object at 0xf3b241cc> def make_objspace(config): from pypy.objspace.std.objspace import StdObjSpace > return StdObjSpace(config) tool/option.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace, config = <rpython.config.config.Config object at 0xf3b241cc> @not_rpython def __init__(self, config=None): "Basic initialization of objects." self.w_default_importlib_import = None self.fromcache = InternalSpaceCache(self).getorbuild self.threadlocals = ThreadLocals() # set recursion limit # sets all the internal descriptors if config is None: from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=False) self.config = config self.reverse_debugging = config.translation.reverse_debugger self.builtin_modules = {} self.reloading_modules = {} self.interned_strings = make_weak_value_dictionary(self, str, W_Root) self.actionflag = ActionFlag() # changed by the signal module self.check_signal_action = None # changed by the signal module make_finalizer_queue(W_Root, self) self._code_of_sys_exc_info = None self._builtin_functions_by_identifier = {'': None} # can be overridden to a subclass > self.initialize() interpreter/baseobjspace.py:481: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject self.IntObjectCls = W_IntObject self.FloatObjectCls = W_FloatObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) self.w_DisallowNew = self.wrap(special.DisallowNew()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup > self.setup_builtin_modules() objspace/std/objspace.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = StdObjSpace @not_rpython def setup_builtin_modules(self): "only for initializing the space." if self.config.objspace.usemodules.cpyext: # Special-case this to have state.install_dll() called early, which # is required to initialise sys on Windows. from pypy.module.cpyext.state import State > self.fromcache(State).build_api() interpreter/baseobjspace.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.state.State instance at 0xf38d8c0c> def build_api(self): """NOT_RPYTHON This function is called when at object space creation, and drives the compilation of the cpyext library """ self.setup_rawrefcount() from pypy.module.cpyext import api if not self.space.config.translating: > self.api_lib = str(api.build_bridge(self.space)) module/cpyext/state.py:128: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace def build_bridge(space): "NOT_RPYTHON" from rpython.translator.c.database import LowLevelDatabase use_micronumpy = setup_micronumpy(space) db = LowLevelDatabase() prefix = 'cpyexttest' generate_decls_and_callbacks(db, prefix=prefix) # Structure declaration code functions = [] members = [] structindex = {} for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): functions.append(func.get_ctypes_impl(name, db)) members.append(func.get_ptr_decl(name, db)) structindex[name] = len(structindex) structmembers = '\n'.join(members) struct_declaration_code = """\ struct PyPyAPI { %(members)s } _pypyAPI; RPY_EXTERN struct PyPyAPI* pypyAPI; struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) prologue = ("#include <Python.h>\n" + "#include <structmember.h>\n" + "#include <marshal.h>\n" + "#include <pycore_namespace.h>\n" + ("#include <pypy_numpy.h>\n" if use_micronumpy else "") + "#include <src/thread.c>\n") code = (prologue + struct_declaration_code + '\n' + '\n'.join(functions)) eci = build_eci(code, use_micronumpy, translating=False) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi"), symbolic=True) space.fromcache(State).install_dll(eci) modulename = py.path.local(eci.libraries[-1]) attach_c_functions(space, eci, prefix) run_bootstrap_functions(space) # load the bridge, and init structure bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) # populate static data builder = space.fromcache(State).builder = TestingObjBuilder() from pypy.module import cpyext # for the eval() below for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: name, header = name.split('#') assert typ in ('PyObject*', 'PyTypeObject*', 'PyIntObject*') isptr = False elif name.startswith('PyExc_'): isptr = False elif typ == 'PyDateTime_CAPI*': isptr = True else: raise ValueError("Unknown static data: %s %s" % (typ, name)) w_obj = eval(expr) INTERPLEVEL_API[name] = w_obj mname = mangle_name(prefix, name) if isptr: assert typ == 'PyDateTime_CAPI*' value = w_obj ptr = ctypes.c_void_p.in_dll(bridge, mname) ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value), ctypes.c_void_p).value elif typ in ('PyObject*', 'PyTypeObject*'): if name.startswith('PyExc_'): # we already have the pointer in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll) else: # we have a structure, get its address in_dll = ll2ctypes.get_ctypes_type(PyObject.TO).in_dll(bridge, mname) py_obj = ll2ctypes.ctypes2lltype(PyObject, ctypes.pointer(in_dll)) builder.prepare(py_obj, w_obj) pypyAPI = ctypes.POINTER(ctypes.c_void_p).in_dll(bridge, 'pypyAPI') # implement structure initialization code for header, header_functions in FUNCTIONS_BY_HEADER.iteritems(): for name, func in header_functions.iteritems(): pypyAPI[structindex[name]] = ctypes.cast( ll2ctypes.lltype2ctypes(func.get_llhelper(space)), ctypes.c_void_p) # we need to call this *after* the init code above, because it might # indirectly call some functions which are attached to pypyAPI (e.g., we # if do tuple_attach of the prebuilt empty tuple, we need to call # _PyPy_Malloc) > builder.attach_all(space) module/cpyext/api.py:1468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pypy.module.cpyext.api.TestingObjBuilder object at 0xf3caddec> space = StdObjSpace def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_static_reference # static_pyobjs = self.get_static_pyobjs() static_objs_w = self.static_objs_w # Static objects are immortal and exempt from the ob_pypy_link prefix: they # are mapped out-of-band (constant tables + _Py_IMMORTAL_REFCNT) rather # than rawrefcount-linked. See rawrefcount.rst. for i in range(len(static_objs_w)): track_static_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): > attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) module/cpyext/api.py:1535: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace static_pyobjs = [<* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4162020>>, <* <C object Struct _object { c_ob_refcnt, c_... c_ob_refcnt, c_ob_type } at 0xf41623a0>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xf4162480>>, ...] static_objs_w = [<W_TypeObject 'reversed' at 0xf3ce23ec>, <W_TypeObject 'MemoryError' at 0xf3b1fa4c>, <W_TypeObject 'bytearray' at 0xf...or' at 0xf38ccdac>, <W_TypeObject 'cinstancemethod' at 0xf3cc8f0c>, <W_TypeObject 'AttributeError' at 0xf4190e4c>, ...] attached_objs = [101, 0, 58, 93, 1, 2, ...], i = 54 def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: return py_obj = static_pyobjs[i] w_obj = static_objs_w[i] w_base = None # w_obj can be NotImplemented, which is not a W_TypeObject if isinstance(w_obj, W_TypeObject): bases_w = w_obj.bases_w if bases_w: w_base = find_best_base(bases_w) if w_base: try: j = static_objs_w.index(w_base) except ValueError: j = -1 if j >=0 and j not in attached_objs: attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, > make_ref(space, w_type)) module/cpyext/api.py:1497: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3cf84cc> w_userdata = None, immortal = False def make_ref(space, w_obj, w_userdata=None, immortal=False): """Turn the W_Root into a corresponding PyObject. You should decref the returned PyObject later. Note that it is often the case, but not guaranteed, that make_ref() returns always the same PyObject for the same W_Root; for example, integers. """ assert not is_pyobj(w_obj) if False and w_obj is not None and space.type(w_obj) is space.w_int: # XXX: adapt for pypy3 state = space.fromcache(State) intval = space.int_w(w_obj) return state.ccall("PyLong_FromLong", intval) > return get_pyobj_and_incref(space, w_obj, w_userdata, immortal=False) module/cpyext/pyobject.py:510: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3cf84cc> w_userdata = None, immortal = False def get_pyobj_and_incref(space, w_obj, w_userdata=None, immortal=False): > pyobj = as_pyobj(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:483: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3cf84cc> w_userdata = None, immortal = False @jit.dont_look_inside def as_pyobj(space, w_obj, w_userdata=None, immortal=False): """ Returns a 'PyObject *' representing the given interpreter object. This doesn't give a new reference, but the returned 'PyObject *' is valid at least as long as 'w_obj' is. **To be safe, you should use keepalive_until_here(w_obj) some time later.** In case of doubt, use the safer make_ref(). """ assert not is_pyobj(w_obj) if w_obj is not None: py_obj = w_obj._cpyext_as_pyobj(space) if not py_obj: > py_obj = create_ref(space, w_obj, w_userdata, immortal=immortal) module/cpyext/pyobject.py:445: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace, w_obj = <W_TypeObject 'ellipsis' at 0xf3cf84cc> w_userdata = None, immortal = False @jit.dont_look_inside def create_ref(space, w_obj, w_userdata=None, immortal=False): """ Allocates a PyObject, and fills its fields with info from the given interpreter object. """ w_type = space.type(w_obj) pytype = rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_type)) typedescr = get_typedescr(w_obj.typedef) if space.is_w(w_type, space.w_text): # These PyUnicodeObjects will always take the compact form # since they come from uint8-encoded strings, so we must # override the default tp_itemsize (see also unicode_alloc) # Maybe this snippet should use the ptype.tp_alloc to allocate the py_obj? itemsize = 1 elif space.is_w(w_type, space.w_type): # Subclasses of "type" (which has space for PyMemberDef) do not # need space for tp_member like heap types do itemsize = 0 else: itemsize = pytype.c_tp_itemsize if itemsize != 0 or space.issubtype_w(w_type, space.w_list): # PyBytesObject, compact PyUnicodeObject and subclasses try: # Can cause infinite recursion if w_obj.__len__ is a c function # so the call will try to convert w_obj to a pyobj via create_ref from pypy.objspace.std.listobject import W_ListObject if isinstance(w_obj, W_ListObject): itemcount = w_obj.length() else: itemcount = space.len_w(w_obj) except OperationError as e: if e.match(space, space.w_TypeError): # issue 4013: is this correct? itemcount = 0 # raise oefmt(space.w_SystemError, # "cpyext: Failure to allocate '%N' (with a non-zero " # "tp_itemsize) when len(obj) cannot be calculated", # w_type) else: raise else: itemcount = 0 py_obj = typedescr.allocate(space, w_type, itemcount=itemcount, immortal=immortal) > track_reference(space, py_obj, w_obj) module/cpyext/pyobject.py:326: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ space = StdObjSpace py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x92f5940>> w_obj = <W_TypeObject 'ellipsis' at 0xf3cf84cc> def track_reference(space, py_obj, w_obj): """ Ties py_obj's prefix (marked by refcnt >= REFCNT_FROM_PYPY) to w_obj. A foreign py_obj (below the tag, no prefix) is left unlinked. """ # XXX looks like a PyObject_GC_TRACK if py_obj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY: > w_obj._cpyext_attach_pyobj(space, py_obj) module/cpyext/pyobject.py:375: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ command interrupted, attempting to kill process killed by signal 9 program finished with exit code -1 elapsedTime=4212.165421