Skip to content

Commit 09bb918

Browse files
Fix fuzz testing for marshal.loads(). (GH-8106)
1 parent fc05e68 commit 09bb918

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Lib/test/test_marshal.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ def test_bug_5888452(self):
192192
marshal.dumps([128] * 1000)
193193

194194
def test_patch_873224(self):
195-
self.assertRaises(Exception, marshal.loads, '0')
196-
self.assertRaises(Exception, marshal.loads, 'f')
195+
self.assertRaises(Exception, marshal.loads, b'0')
196+
self.assertRaises(Exception, marshal.loads, b'f')
197197
self.assertRaises(Exception, marshal.loads, marshal.dumps(2**65)[:-1])
198198

199199
def test_version_argument(self):
@@ -204,7 +204,8 @@ def test_version_argument(self):
204204
def test_fuzz(self):
205205
# simple test that it's at least not *totally* trivial to
206206
# crash from bad marshal data
207-
for c in [chr(i) for i in range(256)]:
207+
for i in range(256):
208+
c = bytes([i])
208209
try:
209210
marshal.loads(c)
210211
except Exception:
@@ -318,7 +319,7 @@ def readinto(self, buf):
318319
self.assertRaises(ValueError, marshal.load,
319320
BadReader(marshal.dumps(value)))
320321

321-
def _test_eof(self):
322+
def test_eof(self):
322323
data = marshal.dumps(("hello", "dolly", None))
323324
for i in range(len(data)):
324325
self.assertRaises(EOFError, marshal.loads, data[0: i])

0 commit comments

Comments
 (0)