test_sys.py 文件源码

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

项目:zippy 作者: securesystemslab 项目源码 文件源码
def test_recursionlimit_fatalerror(self):
        # A fatal error occurs if a second recursion limit is hit when recovering
        # from a first one.
        if os.name == "nt":
            raise unittest.SkipTest(
                "under Windows, test would generate a spurious crash dialog")
        code = textwrap.dedent("""
            import sys

            def f():
                try:
                    f()
                except RuntimeError:
                    f()

            sys.setrecursionlimit(%d)
            f()""")
        for i in (50, 1000):
            sub = subprocess.Popen([sys.executable, '-c', code % i],
                stderr=subprocess.PIPE)
            err = sub.communicate()[1]
            self.assertTrue(sub.returncode, sub.returncode)
            self.assertTrue(
                b"Fatal Python error: Cannot recover from stack overflow" in err,
                err)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号