本文整理汇总了Python中pypy.interpreter.baseobjspace.ObjSpace.exception_match方法的典型用法代码示例。如果您正苦于以下问题:Python ObjSpace.exception_match方法的具体用法?Python ObjSpace.exception_match怎么用?Python ObjSpace.exception_match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.interpreter.baseobjspace.ObjSpace
的用法示例。
在下文中一共展示了ObjSpace.exception_match方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exception_match
# 需要导入模块: from pypy.interpreter.baseobjspace import ObjSpace [as 别名]
# 或者: from pypy.interpreter.baseobjspace.ObjSpace import exception_match [as 别名]
def exception_match(self, w_exc_type, w_check_class):
try:
check_class = self.unwrap(w_check_class)
except UnwrapException:
raise Exception, "non-constant except guard"
if not isinstance(check_class, tuple):
# the simple case
return ObjSpace.exception_match(self, w_exc_type, w_check_class)
# checking a tuple of classes
for w_klass in self.viewiterable(w_check_class):
if ObjSpace.exception_match(self, w_exc_type, w_klass):
return True
return False
示例2: exception_match
# 需要导入模块: from pypy.interpreter.baseobjspace import ObjSpace [as 别名]
# 或者: from pypy.interpreter.baseobjspace.ObjSpace import exception_match [as 别名]
def exception_match(self, w_exc_type, w_check_class):
try:
check_class = self.unwrap(w_check_class)
except UnwrapException:
raise Exception, "non-constant except guard"
if check_class in (NotImplementedError, AssertionError):
raise error.FlowingError("Catching %s is not valid in RPython" % check_class.__name__)
if not isinstance(check_class, tuple):
# the simple case
return ObjSpace.exception_match(self, w_exc_type, w_check_class)
# special case for StackOverflow (see rlib/rstackovf.py)
if check_class == rstackovf.StackOverflow:
w_real_class = self.wrap(rstackovf._StackOverflow)
return ObjSpace.exception_match(self, w_exc_type, w_real_class)
# checking a tuple of classes
for w_klass in self.fixedview(w_check_class):
if self.exception_match(w_exc_type, w_klass):
return True
return False