Skip to content

Commit df9b762

Browse files
authored
Add test_load_build_falsey_state
Added 6 tests where the `state` is falsey but not None, and the `inst` value is invalid - these should throw an AttributeError because the `__dict__` attribute doesn't exist for `inst`. In `pickle.py`, if `state` is falsey but not None code is never run to check that `inst` is a valid object (but it does happen in the C accelerator).
1 parent 5fdaee7 commit df9b762

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/test/pickletester.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,14 @@ def test_zero_padded_integers(self):
10241024
self.assertEqual(self.loads(b'L010L\n.'), 10)
10251025
self.assertEqual(self.loads(b'L-010L\n.'), -10)
10261026

1027+
def test_load_build_falsey_state(self):
1028+
self.assertRaises(AttributeError, self.loads, b']]b.')
1029+
self.assertRaises(AttributeError, self.loads, b']K\x00b.')
1030+
self.assertRaises(AttributeError, self.loads, b'])b.')
1031+
self.assertRaises(AttributeError, self.loads, b']}b.')
1032+
self.assertRaises(AttributeError, self.loads, b']\x8fb.')
1033+
self.assertRaises(AttributeError, self.loads, b']\x89b.')
1034+
10271035
def test_nondecimal_integers(self):
10281036
self.assertRaises(ValueError, self.loads, b'I0b10\n.')
10291037
self.assertRaises(ValueError, self.loads, b'I0o10\n.')

0 commit comments

Comments
 (0)