From 74c71f5a624cef653c7da470607ca063b749ef75 Mon Sep 17 00:00:00 2001 From: Amaury Forgeot d'Arc Date: Mon, 26 May 2008 21:41:42 +0000 Subject: #2957: marshal recursion limit exceeded when importing a large .pyc file --- Lib/test/test_marshal.py | 6 ++++++ Misc/NEWS | 4 ++++ Python/marshal.c | 2 -- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py index 83ab852..6e3efe4 100644 --- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -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, diff --git a/Misc/NEWS b/Misc/NEWS index 343bc01..b4f7fdd 100644 --- 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. diff --git a/Python/marshal.c b/Python/marshal.c index f7eb445..b1c8dd6 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -913,8 +913,6 @@ r_object(RFILE *p) Py_XDECREF(filename); Py_XDECREF(name); Py_XDECREF(lnotab); - - return v; } retval = v; break; -- cgit v0.12