vmtest.py 文件源码

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

项目:tailbiter 作者: darius 项目源码 文件源码
def run_in_real_python(self, code):
        real_stdout = sys.stdout

        py_stdout = io.StringIO()
        sys.stdout = py_stdout

        py_value = py_exc = None
        globs = {
            '__builtins__': __builtins__,
            '__name__': '__main__',
            '__doc__': None,
            '__package__': None,
        }

        try:
            py_value = eval(code, globs, globs)
        except AssertionError:              # pragma: no cover
            raise
        except Exception as e:
            py_exc = e
        finally:
            sys.stdout = real_stdout

        return py_value, py_exc, py_stdout
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号