pypy/module/_cffi_backend/test/test_recompiler.py::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 0x00000000161a1178>, 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 0x00007f6da0e916a8>
hook = <_HookCaller 'pytest_runtest_setup'>
methods = [<_pytest.vendored_packages.pluggy.HookImpl instance at 0x00007f6da0f6eba0>, <_pytest.vendored_packages.pluggy.HookImp...y.HookImpl instance at 0x0000000001739760>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0x00000000017397a0>]
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 0x00007f6da0f6eba0>, <_pytest.vendored_packages.pluggy.HookImp...y.HookImpl instance at 0x0000000001739760>, <_pytest.vendored_packages.pluggy.HookImpl instance at 0x00000000017397a0>]
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 0x0000000023dc8340>
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 0x000000000a5615e0>
def get_result(self):
if self.excinfo is None:
return self.result
else:
ex = self.excinfo
if _py3:
raise ex[1].with_traceback(ex[2])
> _reraise(*ex) # noqa
../_pytest/vendored_packages/pluggy.py:279:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0x000000000a5615e0>
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 0x00000000249ecf70>
key = (((True, True, True, True, False, False, ...), 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 0x00000000249ecf70>
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 0x00000000249ecf70>
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 0x00000000249ecf70>
@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 0x000000000a44ec20>
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 0x000000001aa93718>
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 0x7f6da1672e40>>, <* <C object Struct _object { c_ob_refcnt...fcnt, c_ob_type } at 0x7f6da1672e80>>, <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0x7f6da1672ea0>>, ...]
static_objs_w = [<pypy.objspace.std.noneobject.W_NoneObject object at 0x0000000006ee8e20>, W_BoolObject(True), W_BoolObject(False), <p...8>, <pypy.interpreter.special.Ellipsis object at 0x00000000249ed6e0>, <W_TypeObject 'GenericAlias' at 0x25203050>, ...]
attached_objs = [0, 1, 2, 3], i = 4
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 0x233dd1d8>
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 0x233dd1d8>
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 0x233dd1d8>
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 0x233dd1d8>
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 0xac023c0>>
w_obj = <W_TypeObject 'ellipsis' at 0x233dd1d8>
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 0x233dd1d8>, space = StdObjSpace
py_obj = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xac023c0>>
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 0x233dd1d8>
ob = <* <C object Struct _object { c_ob_refcnt, c_ob_type } at 0xac023c0>>
@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 0xac023c0>>
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 0xac023c0>>
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
builder: own-linux-x86-64 build #10996+
test: pypy/module/_cffi_backend/test/test_recompiler.py::AppTestRecompiler::()::test_volatile_fields