summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-07-05 09:19:19 (GMT)
committerGitHub <noreply@github.com>2018-07-05 09:19:19 (GMT)
commit09bb918a61031377d720f1a0fa1fe53c962791b6 (patch)
treeb1279a2b1964a830ba672169bce950af2f6131ba /Lib
parentfc05e68d8fac70349b7ea17ec14e7e0cfa956121 (diff)
downloadcpython-09bb918a61031377d720f1a0fa1fe53c962791b6.zip
cpython-09bb918a61031377d720f1a0fa1fe53c962791b6.tar.gz
cpython-09bb918a61031377d720f1a0fa1fe53c962791b6.tar.bz2
Fix fuzz testing for marshal.loads(). (GH-8106)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_marshal.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index a20ad67..a3bd350 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -192,8 +192,8 @@ class BugsTestCase(unittest.TestCase):
marshal.dumps([128] * 1000)
def test_patch_873224(self):
- self.assertRaises(Exception, marshal.loads, '0')
- self.assertRaises(Exception, marshal.loads, 'f')
+ self.assertRaises(Exception, marshal.loads, b'0')
+ self.assertRaises(Exception, marshal.loads, b'f')
self.assertRaises(Exception, marshal.loads, marshal.dumps(2**65)[:-1])
def test_version_argument(self):
@@ -204,7 +204,8 @@ class BugsTestCase(unittest.TestCase):
def test_fuzz(self):
# simple test that it's at least not *totally* trivial to
# crash from bad marshal data
- for c in [chr(i) for i in range(256)]:
+ for i in range(256):
+ c = bytes([i])
try:
marshal.loads(c)
except Exception:
@@ -318,7 +319,7 @@ class BugsTestCase(unittest.TestCase):
self.assertRaises(ValueError, marshal.load,
BadReader(marshal.dumps(value)))
- def _test_eof(self):
+ def test_eof(self):
data = marshal.dumps(("hello", "dolly", None))
for i in range(len(data)):
self.assertRaises(EOFError, marshal.loads, data[0: i])