pypy/module/cpyext/test/test_import.py::TestImport::()::test_reload
self = <pypy.module.cpyext.test.test_import.TestImport object at 0x7f01c1eef2d0>
space = StdObjSpace
def test_reload(self, space):
stat = PyImport_Import(space, space.wrap("stat"))
space.delattr(stat, space.wrap("S_IMODE"))
> stat = PyImport_ReloadModule(space, stat)
module/cpyext/test/test_import.py:40:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
module/cpyext/api.py:449: in unwrapper
result = self.callable(space, *newargs)
module/cpyext/import_.py:79: in PyImport_ReloadModule
w_imp = space.call_function(w_import, space.newtext('imp'))
interpreter/baseobjspace.py:1237: in call_function
return w_func.funccall(*args_w)
interpreter/function.py:138: in funccall
return self.call_args(Arguments(self.space, list(args_w)))
interpreter/function.py:82: in call_args
w_res = self.getcode().funcrun(self, args)
interpreter/gateway.py:869: in funcrun
return BuiltinCode.funcrun_obj(self, func, None, args)
interpreter/gateway.py:884: in funcrun_obj
self.handle_exception(space, e)
interpreter/gateway.py:878: in funcrun_obj
w_result = activation._run(space, scope_w)
<2206-codegen /build_dir/own-linux-x86-64/build/rpython/tool/sourcetools.py:200>:3: in _run
return self.behavior(space, scope_w[0], scope_w[1], scope_w[2], scope_w[3], scope_w[4])
module/_frozen_importlib/interp_import.py:96: in interp___import__
w_level)
interpreter/baseobjspace.py:1241: in call_function
return self.call_args(w_func, args)
objspace/descroperation.py:192: in call_args
return w_obj.call_args(args)
interpreter/function.py:82: in call_args
w_res = self.getcode().funcrun(self, args)
interpreter/pycode.py:280: in funcrun
return frame.run(func.name, func.qualname)
interpreter/pyframe.py:257: in run
return self.execute_frame()
interpreter/pyframe.py:350: in execute_frame
executioncontext)
interpreter/pyopcode.py:68: in dispatch
next_instr = self.handle_bytecode(co_code, next_instr, ec)
interpreter/pyopcode.py:91: in handle_bytecode
next_instr = self.handle_operation_error(ec, operr)
interpreter/pyopcode.py:74: in handle_bytecode
next_instr = self.dispatch_bytecode(co_code, next_instr, ec)
interpreter/pyopcode.py:307: in dispatch_bytecode
self.CALL_FUNCTION(oparg, next_instr)
interpreter/pyopcode.py:1462: in CALL_FUNCTION
w_result = self.space.call_valuestack(w_function, nargs, self, dropvalues=nargs+1)
interpreter/baseobjspace.py:1264: in call_valuestack
nargs, frame, methodcall=methodcall, dropvalues=dropvalues)
interpreter/function.py:194: in funccall_valuestack
natural_arity - nargs, dropvalues)
interpreter/function.py:232: in _flat_pycall_defaults
return new_frame.run(self.name, self.qualname)
interpreter/pyframe.py:257: in run
return self.execute_frame()
interpreter/pyframe.py:350: in execute_frame
executioncontext)
interpreter/pyopcode.py:68: in dispatch
next_instr = self.handle_bytecode(co_code, next_instr, ec)
interpreter/pyopcode.py:91: in handle_bytecode
next_instr = self.handle_operation_error(ec, operr)
interpreter/pyopcode.py:74: in handle_bytecode
next_instr = self.dispatch_bytecode(co_code, next_instr, ec)
interpreter/pyopcode.py:307: in dispatch_bytecode
self.CALL_FUNCTION(oparg, next_instr)
interpreter/pyopcode.py:1462: in CALL_FUNCTION
w_result = self.space.call_valuestack(w_function, nargs, self, dropvalues=nargs+1)
interpreter/baseobjspace.py:1264: in call_valuestack
nargs, frame, methodcall=methodcall, dropvalues=dropvalues)
interpreter/function.py:188: in funccall_valuestack
return self._flat_pycall(code, nargs, frame, dropvalues)
interpreter/function.py:215: in _flat_pycall
return new_frame.run(self.name, self.qualname)
interpreter/pyframe.py:257: in run
return self.execute_frame()
interpreter/pyframe.py:350: in execute_frame
executioncontext)
interpreter/pyopcode.py:68: in dispatch
next_instr = self.handle_bytecode(co_code, next_instr, ec)
interpreter/pyopcode.py:95: in handle_bytecode
reraise_lasti=e.lasti)
interpreter/pyopcode.py:74: in handle_bytecode
next_instr = self.dispatch_bytecode(co_code, next_instr, ec)
interpreter/pyopcode.py:245: in dispatch_bytecode
return self.RERAISE(oparg, next_instr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pypy.objspace.std.frame.StdObjSpaceFrame executing <code object _find_and_load, file "<frozen importlib._bootstrap>", line 1349> at line 1360
oparg = 1, next_instr = 122L
def RERAISE(self, oparg, next_instr):
# CPython 3.11 RERAISE N semantics: if N > 0, read the lasti (int)
# from PEEK(N + 1) [i.e., N slots below TOS after pushing exc], set
# self.last_instr to it so the re-raised exception's traceback/lineno
# reflect the original raise site, then pop the exception and raise.
# N == 0 is a plain reraise of TOS. Stack before: [..., lasti, exc]
# for N == 1; after: [..., lasti]. The surrounding handler is
# expected to have already done its POP_EXCEPT if sys.exc_info needs
# restoring (PyPy no longer bundles POP_EXCEPT into RERAISE 1).
if oparg:
# PEEK(oparg + 1): 0 == TOS (exc), oparg is the lasti slot.
# Pass via RaiseWithExplicitTraceback rather than self.last_instr:
# the table lookup must use the RERAISE site offset, not lasti.
reraise_lasti = self.space.int_w(self.peekvalue(oparg))
else:
reraise_lasti = -1
w_exc = self.popvalue()
from pypy.module.exceptions.interp_exceptions import W_BaseException
space = self.space
w_value = space.interp_w(W_BaseException, w_exc)
w_type = space.type(w_exc)
operr = OperationError(w_type, w_exc, w_value.w_traceback)
# Raise as RaiseWithExplicitTraceback so that handle_bytecode
# dispatches via its 'except RaiseWithExplicitTraceback' branch
# (calling handle_operation_error with attach_tb=False). This
# avoids a spurious traceback entry and exception_trace call that
# would occur if the OperationError bubbled up to the plain
# 'except OperationError' branch in handle_bytecode.
> raise RaiseWithExplicitTraceback(operr, reraise_lasti)
E OperationError: [<W_TypeObject 'ModuleNotFoundError' at 0x7f01c417f610>: W_ImportErrorUserWeakrefable([W_UnicodeObject("No module named 'imp'")])]
interpreter/pyopcode.py:1456: OperationError
builder: own-linux-x86-64 build #10886+
test: pypy/module/cpyext/test/test_import.py::TestImport::()::test_reload