• Home
  • Raw
  • Download

Lines Matching refs:pickle

8 import pickle
35 from pickle import bytes_types
53 protocols = range(pickle.HIGHEST_PROTOCOL + 1)
57 def opcode_in_pickle(code, pickle): argument
58 for op, dummy, dummy in pickletools.genops(pickle):
64 def count_opcode(code, pickle): argument
66 for op, dummy, dummy in pickletools.genops(pickle):
207 return type(self)._reconstruct, (pickle.PickleBuffer(self),), None
235 return type(self)._reconstruct, (pickle.PickleBuffer(self),), None
312 pb = pickle.PickleBuffer(self.array)
1001 self.assertEqual(self.loads(pickle.BINSTRING +
1003 b'x' * 300 + pickle.STOP,
1030 self.check_unpickling_error((pickle.UnpicklingError, OverflowError),
1037 self.check_unpickling_error((pickle.UnpicklingError, OverflowError),
1045 self.check_unpickling_error(pickle.UnpicklingError, b'g0\np0')
1046 self.check_unpickling_error(pickle.UnpicklingError, b'jens:')
1047 self.check_unpickling_error(pickle.UnpicklingError, b'hens:')
1066 self.check_unpickling_error((pickle.UnpicklingError, OverflowError),
1072 self.check_unpickling_error((pickle.UnpicklingError, OverflowError),
1078 self.check_unpickling_error((pickle.UnpicklingError, OverflowError),
1135 self.check_unpickling_error(pickle.UnpicklingError, p)
1186 error = (pickle.UnpicklingError, TypeError)
1192 error = (pickle.UnpicklingError, TypeError)
1423 results.append(pickle.loads(pickle_bytes))
1504 for proto in range(minprotocol, pickle.HIGHEST_PROTOCOL + 1):
1525 for proto in range(minprotocol, pickle.HIGHEST_PROTOCOL + 1):
1537 for proto in range(minprotocol, pickle.HIGHEST_PROTOCOL + 1):
1560 for proto in range(minprotocol, pickle.HIGHEST_PROTOCOL + 1):
1581 for proto in range(minprotocol, pickle.HIGHEST_PROTOCOL + 1):
1593 for proto in range(minprotocol, pickle.HIGHEST_PROTOCOL + 1):
1617 for proto in range(minprotocol, pickle.HIGHEST_PROTOCOL + 1):
1640 for proto in range(minprotocol, pickle.HIGHEST_PROTOCOL + 1):
1654 for proto in range(minprotocol, pickle.HIGHEST_PROTOCOL + 1):
1676 for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
1686 for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
1848 self.assertTrue(opcode_in_pickle(pickle.GLOBAL, p))
1851 self.assertTrue(opcode_in_pickle(pickle.STACK_GLOBAL, p))
1854 self.assertTrue(opcode_in_pickle(pickle.BYTEARRAY8, p))
1881 pickle = self.dumps(n, proto)
1882 got = self.loads(pickle)
1903 pickle = self.dumps(value, proto)
1904 got = self.loads(pickle)
1935 copyreg.pickle(pickling_metaclass, pickling_metaclass.__reduce__)
1988 proto_header = pickle.PROTO + bytes([proto])
1991 self.assertEqual(count_opcode(pickle.PROTO, pickled), 0)
1994 build_none = pickle.NONE + pickle.STOP
1995 badpickle = pickle.PROTO + bytes([oob]) + build_none
2009 self.assertEqual(opcode_in_pickle(pickle.LONG1, s), proto >= 2)
2017 self.assertEqual(opcode_in_pickle(pickle.LONG4, s), proto >= 2)
2021 expected_opcode = {(0, 0): pickle.TUPLE,
2022 (0, 1): pickle.TUPLE,
2023 (0, 2): pickle.TUPLE,
2024 (0, 3): pickle.TUPLE,
2025 (0, 4): pickle.TUPLE,
2027 (1, 0): pickle.EMPTY_TUPLE,
2028 (1, 1): pickle.TUPLE,
2029 (1, 2): pickle.TUPLE,
2030 (1, 3): pickle.TUPLE,
2031 (1, 4): pickle.TUPLE,
2033 (2, 0): pickle.EMPTY_TUPLE,
2034 (2, 1): pickle.TUPLE1,
2035 (2, 2): pickle.TUPLE2,
2036 (2, 3): pickle.TUPLE3,
2037 (2, 4): pickle.TUPLE,
2039 (3, 0): pickle.EMPTY_TUPLE,
2040 (3, 1): pickle.TUPLE1,
2041 (3, 2): pickle.TUPLE2,
2042 (3, 3): pickle.TUPLE3,
2043 (3, 4): pickle.TUPLE,
2060 expected_opcode = {(0, None): pickle.NONE,
2061 (1, None): pickle.NONE,
2062 (2, None): pickle.NONE,
2063 (3, None): pickle.NONE,
2065 (0, True): pickle.INT,
2066 (1, True): pickle.INT,
2067 (2, True): pickle.NEWTRUE,
2068 (3, True): pickle.NEWTRUE,
2070 (0, False): pickle.INT,
2071 (1, False): pickle.INT,
2072 (2, False): pickle.NEWFALSE,
2073 (3, False): pickle.NEWFALSE,
2152 self.assertRaises((TypeError, pickle.UnpicklingError), self.loads, b)
2189 self.produce_global_ext(0x00000001, pickle.EXT1) # smallest EXT1 code
2190 self.produce_global_ext(0x000000ff, pickle.EXT1) # largest EXT1 code
2193 self.produce_global_ext(0x00000100, pickle.EXT2) # smallest EXT2 code
2194 self.produce_global_ext(0x0000ffff, pickle.EXT2) # largest EXT2 code
2195 self.produce_global_ext(0x0000abcd, pickle.EXT2) # check endianness
2198 self.produce_global_ext(0x00010000, pickle.EXT4) # smallest EXT4 code
2199 self.produce_global_ext(0x7fffffff, pickle.EXT4) # largest EXT4 code
2200 self.produce_global_ext(0x12abcdef, pickle.EXT4) # check endianness
2209 num_appends = count_opcode(pickle.APPENDS, s)
2218 num_appends = count_opcode(pickle.APPENDS, s)
2232 num_setitems = count_opcode(pickle.SETITEMS, s)
2241 num_setitems = count_opcode(pickle.SETITEMS, s)
2254 num_additems = count_opcode(pickle.ADDITEMS, s)
2266 num_additems = count_opcode(pickle.ADDITEMS, s)
2282 self.assertEqual(opcode_in_pickle(pickle.NEWOBJ, s),
2284 self.assertFalse(opcode_in_pickle(pickle.NEWOBJ_EX, s))
2302 self.assertEqual(opcode_in_pickle(pickle.NEWOBJ, s),
2304 self.assertFalse(opcode_in_pickle(pickle.NEWOBJ_EX, s))
2322 self.assertFalse(opcode_in_pickle(pickle.NEWOBJ, s))
2323 self.assertEqual(opcode_in_pickle(pickle.NEWOBJ_EX, s),
2405 except pickle.PicklingError:
2409 except pickle.PicklingError:
2469 self.assertFalse(opcode_in_pickle(pickle.LONG, p))
2482 self._check_pickling_with_opcode(obj, pickle.APPEND, proto)
2484 self._check_pickling_with_opcode(obj, pickle.APPENDS, proto)
2490 self._check_pickling_with_opcode(obj, pickle.SETITEM, proto)
2492 self._check_pickling_with_opcode(obj, pickle.SETITEMS, proto)
2549 for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
2555 count_opcode(pickle.FRAME, pickled))
2566 for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
2588 n_frames = count_opcode(pickle.FRAME, pickled)
2595 if pickle.HIGHEST_PROTOCOL < 4:
2624 for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
2628 self.assertEqual(count_opcode(pickle.FRAME, frameless_pickle), 0)
2632 self.assertLess(count_opcode(pickle.FRAME, some_frames_pickle),
2633 count_opcode(pickle.FRAME, pickled))
2647 for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
2709 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
2721 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
2765 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
2805 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
2835 for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
2836 with self.assertRaises((AttributeError, pickle.PicklingError)):
2841 for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
2842 with self.assertRaises((AttributeError, pickle.PicklingError)):
2846 for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
2847 with self.assertRaises((AttributeError, pickle.PicklingError)):
2877 for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
2882 self.assertEqual(count_opcode(pickle.NEXT_BUFFER, data), 0)
2884 self.assertEqual(count_opcode(pickle.SHORT_BINBYTES, data),
2886 self.assertEqual(count_opcode(pickle.BYTEARRAY8, data),
2913 for proto in range(5, pickle.HIGHEST_PROTOCOL + 1):
2919 self.assertEqual(count_opcode(pickle.SHORT_BINBYTES, data), 0)
2920 self.assertEqual(count_opcode(pickle.BYTEARRAY8, data), 0)
2921 self.assertEqual(count_opcode(pickle.NEXT_BUFFER, data), 1)
2922 self.assertEqual(count_opcode(pickle.READONLY_BUFFER, data),
2928 with self.assertRaises(pickle.UnpicklingError):
2950 for proto in range(5, pickle.HIGHEST_PROTOCOL + 1):
2962 pb = pickle.PickleBuffer(b"foobar")
2964 with self.assertRaises(pickle.PickleError):
2970 pb = pickle.PickleBuffer(b"foobar")
2975 pb = pickle.PickleBuffer(b"foobar")
2976 for proto in range(5, pickle.HIGHEST_PROTOCOL + 1):
2982 with self.assertRaises(pickle.UnpicklingError):
2986 for proto in range(5, pickle.HIGHEST_PROTOCOL + 1):
3002 for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
3006 for proto in range(5, pickle.HIGHEST_PROTOCOL + 1):
3012 for proto in range(5, pickle.HIGHEST_PROTOCOL + 1):
3067 header = (pickle.BINBYTES +
3094 header = (pickle.BINBYTES8 +
3118 header = (pickle.BINUNICODE +
3149 header = (pickle.BINUNICODE8 +
3337 self.assertEqual(pickle.HIGHEST_PROTOCOL, 5)
3360 self.assertRaises((EOFError, struct.error, pickle.UnpicklingError), self.load, s)
3371 self.assertRaises(pickle.PicklingError, BadPickler().dump, 0)
3372 self.assertRaises(pickle.UnpicklingError, BadUnpickler().load)
3385 for proto in range(5, pickle.HIGHEST_PROTOCOL + 1):
3393 with self.assertRaises(pickle.UnpicklingError):
3480 self.assertRaises(pickle.PicklingError, self.dumps, non_ascii_str, 0)
3481 pickled = pickle.PERSID + non_ascii_str.encode('utf-8') + b'\n.'
3482 self.assertRaises(pickle.UnpicklingError, self.loads, pickled)
3717 for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
3723 new_f, some_str, math_log = pickle.loads(bio.getvalue())
3733 with self.assertRaises(pickle.PicklingError):
3746 for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
3756 new_f = pickle.loads(bio.getvalue())
3807 return pickle.loads(dumps(obj, 0))
3810 return pickle.loads(pickle.dumps(obj, 0))
3876 for i in range(pickle.HIGHEST_PROTOCOL+1):
3877 p = pickle.dumps(x, i)