]> granicus.if.org Git - python/commitdiff
#2957: marshal recursion limit exceeded when importing a large .pyc file
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 26 May 2008 21:41:42 +0000 (21:41 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 26 May 2008 21:41:42 +0000 (21:41 +0000)
Lib/test/test_marshal.py
Misc/NEWS
Python/marshal.c

index 83ab852beca51911704af62b4203a0eaa2a2aaea..6e3efe4a31776509942bf5a7c0d7db555b72f79d 100644 (file)
@@ -113,6 +113,12 @@ class CodeTestCase(unittest.TestCase):
         new = marshal.loads(marshal.dumps(co))
         self.assertEqual(co, new)
 
+    def test_many_codeobjects(self):
+        # Issue2957: bad recursion count on code objects
+        count = 5000    # more than MAX_MARSHAL_STACK_DEPTH
+        codes = (ExceptionTestCase.test_exceptions.__code__,) * count
+        marshal.loads(marshal.dumps(codes))
+
 class ContainerTestCase(unittest.TestCase, HelperMixin):
     d = {'astring': 'foo@bar.baz.spam',
          'afloat': 7283.43,
index 343bc01c9ea868665906dc6e4509379d2f68a5b1..b4f7fddd3c957d120dc2bc0e518d1d2f394cb786 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@ What's new in Python 3.0b1?
 Core and Builtins
 -----------------
 
+- Issue #2957: Corrected a ValueError "recursion limit exceeded", when
+  unmarshalling many code objects, which happens when importing a
+  large .pyc file (~1000 functions).
+
 - Issue #2963: fix merging oversight that disabled method cache for
   all types.
 
index f7eb44551f5b208130e999ec7e6301e27246e110..b1c8dd6f3a8de8df2057587f2842024680ba3a5d 100644 (file)
@@ -913,8 +913,6 @@ r_object(RFILE *p)
                        Py_XDECREF(filename);
                        Py_XDECREF(name);
                        Py_XDECREF(lnotab);
-
-                       return v;
                }
                retval = v;
                break;