本文整理匯總了Python中pypy.interpreter.error.OperationError.set_traceback方法的典型用法代碼示例。如果您正苦於以下問題:Python OperationError.set_traceback方法的具體用法?Python OperationError.set_traceback怎麽用?Python OperationError.set_traceback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pypy.interpreter.error.OperationError
的用法示例。
在下文中一共展示了OperationError.set_traceback方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: w_throw
# 需要導入模塊: from pypy.interpreter.error import OperationError [as 別名]
# 或者: from pypy.interpreter.error.OperationError import set_traceback [as 別名]
def w_throw(self, w_type, w_value=None, w_traceback=None):
space = self.space
operror = OperationError(w_type, w_value)
operror.normalize_exception(space)
if not space.is_w(w_traceback, space.w_None):
from pypy.interpreter import pytraceback
tb = space.interpclass_w(w_traceback)
if tb is None or not space.is_true(space.isinstance(tb,
space.gettypeobject(pytraceback.PyTraceback.typedef))):
raise OperationError(space.w_TypeError,
space.wrap("throw: arg 3 must be a traceback or None"))
operror.set_traceback(tb)
self._kill(operror)
示例2: throw
# 需要導入模塊: from pypy.interpreter.error import OperationError [as 別名]
# 或者: from pypy.interpreter.error.OperationError import set_traceback [as 別名]
def throw(self, w_type, w_val, w_tb):
from pypy.interpreter.pytraceback import check_traceback
space = self.space
msg = "throw() third argument must be a traceback object"
if space.is_none(w_tb):
tb = None
else:
tb = check_traceback(space, w_tb, msg)
operr = OperationError(w_type, w_val, tb)
operr.normalize_exception(space)
if tb is None:
tb = space.getattr(operr.get_w_value(space),
space.wrap('__traceback__'))
if not space.is_w(tb, space.w_None):
operr.set_traceback(tb)
return self.send_ex(space.w_None, operr)
示例3: w_throw
# 需要導入模塊: from pypy.interpreter.error import OperationError [as 別名]
# 或者: from pypy.interpreter.error.OperationError import set_traceback [as 別名]
def w_throw(self, w_type=None, w_value=None, w_traceback=None):
space = self.space
if space.is_w(w_type, space.w_None):
w_type = self.costate.w_GreenletExit
# Code copied from RAISE_VARARGS but slightly modified. Not too nice.
operror = OperationError(w_type, w_value)
operror.normalize_exception(space)
if not space.is_w(w_traceback, space.w_None):
from pypy.interpreter import pytraceback
tb = space.interpclass_w(w_traceback)
if tb is None or not space.is_true(space.isinstance(tb,
space.gettypeobject(pytraceback.PyTraceback.typedef))):
raise OperationError(space.w_TypeError,
space.wrap("throw: arg 3 must be a traceback or None"))
operror.set_traceback(tb)
# Dead greenlet: turn GreenletExit into a regular return
if self.isdead() and operror.match(space, self.costate.w_GreenletExit):
args_w = [operror.get_w_value(space)]
else:
syncstate.push_exception(operror)
args_w = None
return self.w_switch(args_w)