[Python-checkins] Fix fuzz testing for marshal.loads(). (GH-8106)

Miss Islington (bot) webhook-mailer at python.org
Thu Jul 5 06:44:37 EDT 2018


https://github.com/python/cpython/commit/e1adc65c53f5a92dd7c648a3f2a0d9b9cc08419e
commit: e1adc65c53f5a92dd7c648a3f2a0d9b9cc08419e
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018年07月05日T03:44:34-07:00
summary:
Fix fuzz testing for marshal.loads(). (GH-8106)
(cherry picked from commit 09bb918a61031377d720f1a0fa1fe53c962791b6)
Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>
files:
M Lib/test/test_marshal.py
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index c40cdbfa5bee..64a7aa112de7 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -192,8 +192,8 @@ def test_bug_5888452(self):
 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 @@ def test_version_argument(self):
 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:
@@ -315,7 +316,7 @@ def readinto(self, buf):
 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])


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /