]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Tools/scripts/find_recursionlimit.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Tools / scripts / find_recursionlimit.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Tools/scripts/find_recursionlimit.py b/AppPkg/Applications/Python/Python-2.7.2/Tools/scripts/find_recursionlimit.py
deleted file mode 100644 (file)
index 8b578e9..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-#! /usr/bin/env python\r
-"""Find the maximum recursion limit that prevents interpreter termination.\r
-\r
-This script finds the maximum safe recursion limit on a particular\r
-platform.  If you need to change the recursion limit on your system,\r
-this script will tell you a safe upper bound.  To use the new limit,\r
-call sys.setrecursionlimit().\r
-\r
-This module implements several ways to create infinite recursion in\r
-Python.  Different implementations end up pushing different numbers of\r
-C stack frames, depending on how many calls through Python's abstract\r
-C API occur.\r
-\r
-After each round of tests, it prints a message:\r
-"Limit of NNNN is fine".\r
-\r
-The highest printed value of "NNNN" is therefore the highest potentially\r
-safe limit for your system (which depends on the OS, architecture, but also\r
-the compilation flags). Please note that it is practically impossible to\r
-test all possible recursion paths in the interpreter, so the results of\r
-this test should not be trusted blindly -- although they give a good hint\r
-of which values are reasonable.\r
-\r
-NOTE: When the C stack space allocated by your system is exceeded due\r
-to excessive recursion, exact behaviour depends on the platform, although\r
-the interpreter will always fail in a likely brutal way: either a\r
-segmentation fault, a MemoryError, or just a silent abort.\r
-\r
-NB: A program that does not use __methods__ can set a higher limit.\r
-"""\r
-\r
-import sys\r
-import itertools\r
-\r
-class RecursiveBlowup1:\r
-    def __init__(self):\r
-        self.__init__()\r
-\r
-def test_init():\r
-    return RecursiveBlowup1()\r
-\r
-class RecursiveBlowup2:\r
-    def __repr__(self):\r
-        return repr(self)\r
-\r
-def test_repr():\r
-    return repr(RecursiveBlowup2())\r
-\r
-class RecursiveBlowup4:\r
-    def __add__(self, x):\r
-        return x + self\r
-\r
-def test_add():\r
-    return RecursiveBlowup4() + RecursiveBlowup4()\r
-\r
-class RecursiveBlowup5:\r
-    def __getattr__(self, attr):\r
-        return getattr(self, attr)\r
-\r
-def test_getattr():\r
-    return RecursiveBlowup5().attr\r
-\r
-class RecursiveBlowup6:\r
-    def __getitem__(self, item):\r
-        return self[item - 2] + self[item - 1]\r
-\r
-def test_getitem():\r
-    return RecursiveBlowup6()[5]\r
-\r
-def test_recurse():\r
-    return test_recurse()\r
-\r
-def test_cpickle(_cache={}):\r
-    try:\r
-        import cPickle\r
-    except ImportError:\r
-        print "cannot import cPickle, skipped!"\r
-        return\r
-    l = None\r
-    for n in itertools.count():\r
-        try:\r
-            l = _cache[n]\r
-            continue  # Already tried and it works, let's save some time\r
-        except KeyError:\r
-            for i in range(100):\r
-                l = [l]\r
-        cPickle.dumps(l, protocol=-1)\r
-        _cache[n] = l\r
-\r
-def check_limit(n, test_func_name):\r
-    sys.setrecursionlimit(n)\r
-    if test_func_name.startswith("test_"):\r
-        print test_func_name[5:]\r
-    else:\r
-        print test_func_name\r
-    test_func = globals()[test_func_name]\r
-    try:\r
-        test_func()\r
-    # AttributeError can be raised because of the way e.g. PyDict_GetItem()\r
-    # silences all exceptions and returns NULL, which is usually interpreted\r
-    # as "missing attribute".\r
-    except (RuntimeError, AttributeError):\r
-        pass\r
-    else:\r
-        print "Yikes!"\r
-\r
-limit = 1000\r
-while 1:\r
-    check_limit(limit, "test_recurse")\r
-    check_limit(limit, "test_add")\r
-    check_limit(limit, "test_repr")\r
-    check_limit(limit, "test_init")\r
-    check_limit(limit, "test_getattr")\r
-    check_limit(limit, "test_getitem")\r
-    check_limit(limit, "test_cpickle")\r
-    print "Limit of %d is fine" % limit\r
-    limit = limit + 100\r