[Python-3000-checkins] r63731 - in python/branches/py3k: Lib/test/test_marshal.py Misc/NEWS Python/marshal.c

amaury.forgeotdarc python-3000-checkins at python.org
Mon May 26 23:41:43 CEST 2008


Author: amaury.forgeotdarc
Date: Mon May 26 23:41:42 2008
New Revision: 63731

Log:
#2957: marshal recursion limit exceeded when importing a large .pyc file


Modified:
   python/branches/py3k/Lib/test/test_marshal.py
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Python/marshal.c

Modified: python/branches/py3k/Lib/test/test_marshal.py
==============================================================================
--- python/branches/py3k/Lib/test/test_marshal.py	(original)
+++ python/branches/py3k/Lib/test/test_marshal.py	Mon May 26 23:41:42 2008
@@ -113,6 +113,12 @@
         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 at bar.baz.spam',
          'afloat': 7283.43,

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Mon May 26 23:41:42 2008
@@ -12,6 +12,10 @@
 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.
 

Modified: python/branches/py3k/Python/marshal.c
==============================================================================
--- python/branches/py3k/Python/marshal.c	(original)
+++ python/branches/py3k/Python/marshal.c	Mon May 26 23:41:42 2008
@@ -913,8 +913,6 @@
 			Py_XDECREF(filename);
 			Py_XDECREF(name);
 			Py_XDECREF(lnotab);
-
-			return v;
 		}
 		retval = v;
 		break;


More information about the Python-3000-checkins mailing list