def test_recursionlimit(self):
self.assertRaises(TypeError, sys.getrecursionlimit, 42)
oldlimit = sys.getrecursionlimit()
self.assertRaises(TypeError, sys.setrecursionlimit)
self.assertRaises(ValueError, sys.setrecursionlimit, -42)
sys.setrecursionlimit(10000)
self.assertEqual(sys.getrecursionlimit(), 10000)
sys.setrecursionlimit(oldlimit)
self.assertRaises(OverflowError, sys.setrecursionlimit, 1 << 31)
try:
sys.setrecursionlimit((1 << 31) - 5)
try:
# issue13546: isinstance(e, ValueError) used to fail
# when the recursion limit is close to 1<<31
raise ValueError()
except ValueError, e:
pass
finally:
sys.setrecursionlimit(oldlimit)
评论列表
文章目录