pypy/module/cpyext/test/test_import.py::TestImport::()::test_ImportModuleLevelObject
self = <pypy.module.cpyext.test.test_import.TestImport object at 0x7f01c21e8f10>
space = StdObjSpace
def test_ImportModuleLevelObject(self, space):
w_mod = PyImport_ImportModuleLevelObject(
space, space.wrap('stat'), None, None, None, 0)
assert w_mod
> assert space.getattr(w_mod, space.wrap("S_IMODE"))
module/cpyext/test/test_import.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
objspace/std/objspace.py:670: in getattr
return self._handle_getattribute(w_descr, w_obj, w_name)
objspace/descroperation.py:238: in _handle_getattribute
return space.get_and_call_function(w_descr, w_obj, w_name)
objspace/descroperation.py:183: in get_and_call_function
return w_descr.funccall(w_obj, *args_w)
interpreter/function.py:115: in funccall
return code.fastcall_2(self.space, self, args_w[0], args_w[1])
interpreter/gateway.py:1006: in fastcall_2
self.handle_exception(space, e)
interpreter/gateway.py:1001: in fastcall_2
w_result = self.fastfunc_2(space, w1, w2)
<314-codegen /build_dir/own-linux-x86-64/build/rpython/tool/sourcetools.py:200>:3: in fastfunc_descr_getattribute_2
return func(space.interp_w(Module, w0), space, w1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pypy.interpreter.module.Module object at 0x7f01c2a58f50>
space = StdObjSpace, w_attr = W_UnicodeObject('S_IMODE')
def descr_getattribute(self, space, w_attr):
from pypy.objspace.descroperation import object_getattribute
from pypy.module.imp.importing import (is_spec_initializing,
is_spec_uninitialized_submodule)
try:
return space.call_function(object_getattribute(space), self, w_attr)
except OperationError as e:
if not e.match(space, space.w_AttributeError):
raise
w_dict = self.w_dict
w_getattr = space.finditem(w_dict, space.newtext('__getattr__'))
if w_getattr is not None:
return space.call_function(w_getattr, w_attr)
w_name = space.finditem(self.w_dict, space.newtext('__name__'))
w_spec = space.finditem(self.w_dict, space.newtext('__spec__'))
if w_name is None:
raise oefmt(space.w_AttributeError,
"module has no attribute %R", w_attr)
elif w_spec is not None and is_spec_initializing(space, w_spec):
raise oefmt(space.w_AttributeError,
"partially initialized "
"module %R has no attribute %R "
"(most likely due to a circular import)",
w_name, w_attr
)
elif w_spec is not None and is_spec_uninitialized_submodule(space, w_spec, w_attr):
raise oefmt(space.w_AttributeError,
"cannot access submodule %R of module %R "
"(most likely due to a circular import)",
w_attr, w_name)
else:
raise oefmt(space.w_AttributeError,
> "module %R has no attribute %R", w_name, w_attr)
E OpErrFmt: [<W_TypeObject 'AttributeError' at 0x7f01c4122950>: module 'stat' has no attribute 'S_IMODE']
interpreter/module.py:162: OpErrFmt
builder: own-linux-x86-64 build #10886+
test: pypy/module/cpyext/test/test_import.py::TestImport::()::test_ImportModuleLevelObject