summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_marshal.py8
-rw-r--r--Python/marshal.c5
2 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index 1b2c8b7..943aa55 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -255,6 +255,14 @@ class BugsTestCase(unittest.TestCase):
subtyp = type('subtyp', (typ,), {})
self.assertRaises(ValueError, marshal.dumps, subtyp())
+ # Issue #1792 introduced a change in how marshal increases the size of its
+ # internal buffer; this test ensures that the new code is exercised.
+ def test_large_marshal(self):
+ size = int(1e6)
+ testString = 'abc' * size
+ marshal.dumps(testString)
+
+
def test_main():
test_support.run_unittest(IntTestCase,
FloatTestCase,
diff --git a/Python/marshal.c b/Python/marshal.c
index 6ca3495..6db46e4 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -65,7 +65,10 @@ w_more(int c, WFILE *p)
if (p->str == NULL)
return; /* An error already occurred */
size = PyString_Size(p->str);
- newsize = size + 1024;
+ newsize = size + size + 1024;
+ if (newsize > 32*1024*1024) {
+ newsize = size + 1024*1024;
+ }
if (_PyString_Resize(&p->str, newsize) != 0) {
p->ptr = p->end = NULL;
}