summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_marshal.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_marshal.py')
-rw-r--r--Lib/test/test_marshal.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index 292746b..ab06237 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -2,6 +2,7 @@
from test import support
import array
+import io
import marshal
import sys
import unittest
@@ -259,6 +260,17 @@ class BugsTestCase(unittest.TestCase):
unicode_string = 'T'
self.assertRaises(TypeError, marshal.loads, unicode_string)
+ def test_bad_reader(self):
+ class BadReader(io.BytesIO):
+ def read(self, n=-1):
+ b = super().read(n)
+ if n is not None and n > 4:
+ b += b' ' * 10**6
+ return b
+ for value in (1.0, 1j, b'0123456789', '0123456789'):
+ self.assertRaises(ValueError, marshal.load,
+ BadReader(marshal.dumps(value)))
+
def _test_eof(self):
data = marshal.dumps(("hello", "dolly", None))
for i in range(len(data)):