__init__.py 文件源码

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

项目:hostapd-mana 作者: adde88 项目源码 文件源码
def install_importhook(config):
    """Try to install the rewrite hook, raise SystemError if it fails."""
    # Both Jython and CPython 2.6.0 have AST bugs that make the
    # assertion rewriting hook malfunction.
    if (sys.platform.startswith('java') or
            sys.version_info[:3] == (2, 6, 0)):
        raise SystemError('rewrite not supported')

    config._assertstate = AssertionState(config, 'rewrite')
    config._assertstate.hook = hook = rewrite.AssertionRewritingHook(config)
    sys.meta_path.insert(0, hook)
    config._assertstate.trace('installed rewrite import hook')
    def undo():
        hook = config._assertstate.hook
        if hook is not None and hook in sys.meta_path:
            sys.meta_path.remove(hook)
    config.add_cleanup(undo)
    return hook
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号