def _translate_handler(self, handler):
if not isinstance(handler.type, ast.Name) or handler.type.id not in self._exceptions:
raise PseudoPythonTypeCheckError('%s' % str(ast.dump(handler.type)))
h = self.type_env[handler.name]
if h and h != 'Exception':
raise PseudoPythonTypeCheckError("can't change the type of exception %s to %s" % (handler.name, serialize_type(h)))
self.type_env[handler.name] = 'Exception'
return {
'type': 'exception_handler',
'pseudo_type': 'Void',
'exception': handler.type.id,
'is_builtin': handler.type.id == 'Exception',
'instance': handler.name,
'block': self._translate_node(handler.body)
#block [self._translate_node(z) for z in handler.body]
}
评论列表
文章目录