ast_translator.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:pseudo-python 作者: alehander42 项目源码 文件源码
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]
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号