@@ -1176,6 +1176,24 @@ def test_compat_unpickle(self):
11761176 self .assertIs (type (unpickled ), collections .UserDict )
11771177 self .assertEqual (unpickled , collections .UserDict ({1 : 2 }))
11781178
1179+ def test_bad_reduce (self ):
1180+ self .assertEqual (self .loads (b'cbuiltins\n int\n )R.' ), 0 )
1181+ self .check_unpickling_error (TypeError , b'N)R.' )
1182+ self .check_unpickling_error (TypeError , b'cbuiltins\n int\n NR.' )
1183+
1184+ def test_bad_newobj (self ):
1185+ error = (pickle .UnpicklingError , TypeError )
1186+ self .assertEqual (self .loads (b'cbuiltins\n int\n )\x81 .' ), 0 )
1187+ self .check_unpickling_error (error , b'cbuiltins\n len\n )\x81 .' )
1188+ self .check_unpickling_error (error , b'cbuiltins\n int\n N\x81 .' )
1189+
1190+ def test_bad_newobj_ex (self ):
1191+ error = (pickle .UnpicklingError , TypeError )
1192+ self .assertEqual (self .loads (b'cbuiltins\n int\n )}\x92 .' ), 0 )
1193+ self .check_unpickling_error (error , b'cbuiltins\n len\n )}\x92 .' )
1194+ self .check_unpickling_error (error , b'cbuiltins\n int\n N}\x92 .' )
1195+ self .check_unpickling_error (error , b'cbuiltins\n int\n )N\x92 .' )
1196+
11791197 def test_bad_stack (self ):
11801198 badpickles = [
11811199 b'.' , # STOP
0 commit comments