Commit fa310ee3 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Use pickled data compatible with Python 2 for testing protocols 0-2.

parent 56abe390
...@@ -144,21 +144,22 @@ def create_dynamic_class(name, bases): ...@@ -144,21 +144,22 @@ def create_dynamic_class(name, bases):
# the object returned by create_data(). # the object returned by create_data().
DATA0 = ( DATA0 = (
b'(lp0\nL0L\naL1L\naF2.0\nac' b'(lp0\nL0L\naL1L\naF2.0\n'
b'builtins\ncomplex\n' b'ac__builtin__\ncomple'
b'p1\n(F3.0\nF0.0\ntp2\nRp' b'x\np1\n(F3.0\nF0.0\ntp2\n'
b'3\naL1L\naL-1L\naL255L\naL-' b'Rp3\naL1L\naL-1L\naL255'
b'255L\naL-256L\naL65535L\na' b'L\naL-255L\naL-256L\naL'
b'L-65535L\naL-65536L\naL2' b'65535L\naL-65535L\naL-'
b'147483647L\naL-2147483' b'65536L\naL2147483647L'
b'647L\naL-2147483648L\na(' b'\naL-2147483647L\naL-2'
b'Vabc\np4\ng4\nccopyreg' b'147483648L\na(Vabc\np4'
b'\n_reconstructor\np5\n(' b'\ng4\nccopy_reg\n_recon'
b'c__main__\nC\np6\ncbu' b'structor\np5\n(c__main'
b'iltins\nobject\np7\nNt' b'__\nC\np6\nc__builtin__'
b'p8\nRp9\n(dp10\nVfoo\np1' b'\nobject\np7\nNtp8\nRp9\n'
b'1\nL1L\nsVbar\np12\nL2L\nsb' b'(dp10\nVfoo\np11\nL1L\ns'
b'g9\ntp13\nag13\naL5L\na.' b'Vbar\np12\nL2L\nsbg9\ntp'
b'13\nag13\naL5L\na.'
) )
# Disassembly of DATA0 # Disassembly of DATA0
...@@ -172,88 +173,88 @@ DATA0_DIS = """\ ...@@ -172,88 +173,88 @@ DATA0_DIS = """\
14: a APPEND 14: a APPEND
15: F FLOAT 2.0 15: F FLOAT 2.0
20: a APPEND 20: a APPEND
21: c GLOBAL 'builtins complex' 21: c GLOBAL '__builtin__ complex'
39: p PUT 1 42: p PUT 1
42: ( MARK 45: ( MARK
43: F FLOAT 3.0 46: F FLOAT 3.0
48: F FLOAT 0.0 51: F FLOAT 0.0
53: t TUPLE (MARK at 42) 56: t TUPLE (MARK at 45)
54: p PUT 2 57: p PUT 2
57: R REDUCE 60: R REDUCE
58: p PUT 3 61: p PUT 3
61: a APPEND 64: a APPEND
62: L LONG 1 65: L LONG 1
66: a APPEND 69: a APPEND
67: L LONG -1 70: L LONG -1
72: a APPEND 75: a APPEND
73: L LONG 255 76: L LONG 255
79: a APPEND 82: a APPEND
80: L LONG -255 83: L LONG -255
87: a APPEND 90: a APPEND
88: L LONG -256 91: L LONG -256
95: a APPEND 98: a APPEND
96: L LONG 65535 99: L LONG 65535
104: a APPEND 107: a APPEND
105: L LONG -65535 108: L LONG -65535
114: a APPEND 117: a APPEND
115: L LONG -65536 118: L LONG -65536
124: a APPEND 127: a APPEND
125: L LONG 2147483647 128: L LONG 2147483647
138: a APPEND 141: a APPEND
139: L LONG -2147483647 142: L LONG -2147483647
153: a APPEND 156: a APPEND
154: L LONG -2147483648 157: L LONG -2147483648
168: a APPEND 171: a APPEND
169: ( MARK 172: ( MARK
170: V UNICODE 'abc' 173: V UNICODE 'abc'
175: p PUT 4 178: p PUT 4
178: g GET 4 181: g GET 4
181: c GLOBAL 'copyreg _reconstructor' 184: c GLOBAL 'copy_reg _reconstructor'
205: p PUT 5 209: p PUT 5
208: ( MARK 212: ( MARK
209: c GLOBAL '__main__ C' 213: c GLOBAL '__main__ C'
221: p PUT 6 225: p PUT 6
224: c GLOBAL 'builtins object' 228: c GLOBAL '__builtin__ object'
241: p PUT 7 248: p PUT 7
244: N NONE 251: N NONE
245: t TUPLE (MARK at 208) 252: t TUPLE (MARK at 212)
246: p PUT 8 253: p PUT 8
249: R REDUCE 256: R REDUCE
250: p PUT 9 257: p PUT 9
253: ( MARK 260: ( MARK
254: d DICT (MARK at 253) 261: d DICT (MARK at 260)
255: p PUT 10 262: p PUT 10
259: V UNICODE 'foo' 266: V UNICODE 'foo'
264: p PUT 11 271: p PUT 11
268: L LONG 1 275: L LONG 1
272: s SETITEM 279: s SETITEM
273: V UNICODE 'bar' 280: V UNICODE 'bar'
278: p PUT 12 285: p PUT 12
282: L LONG 2 289: L LONG 2
286: s SETITEM 293: s SETITEM
287: b BUILD 294: b BUILD
288: g GET 9 295: g GET 9
291: t TUPLE (MARK at 169) 298: t TUPLE (MARK at 172)
292: p PUT 13 299: p PUT 13
296: a APPEND 303: a APPEND
297: g GET 13 304: g GET 13
301: a APPEND 308: a APPEND
302: L LONG 5 309: L LONG 5
306: a APPEND 313: a APPEND
307: . STOP 314: . STOP
highest protocol among opcodes = 0 highest protocol among opcodes = 0
""" """
DATA1 = ( DATA1 = (
b']q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c' b']q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c__'
b'builtins\ncomplex\nq\x01' b'builtin__\ncomplex\nq\x01'
b'(G@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00t' b'(G@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00t'
b'q\x02Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xffJ' b'q\x02Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xffJ'
b'\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff\xff' b'\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff\xff'
b'\xff\x7fJ\x01\x00\x00\x80J\x00\x00\x00\x80(X\x03\x00\x00\x00ab' b'\xff\x7fJ\x01\x00\x00\x80J\x00\x00\x00\x80(X\x03\x00\x00\x00ab'
b'cq\x04h\x04ccopyreg\n_reco' b'cq\x04h\x04ccopy_reg\n_reco'
b'nstructor\nq\x05(c__main' b'nstructor\nq\x05(c__main'
b'__\nC\nq\x06cbuiltins\n' b'__\nC\nq\x06c__builtin__\n'
b'object\nq\x07Ntq\x08Rq\t}q\n(' b'object\nq\x07Ntq\x08Rq\t}q\n('
b'X\x03\x00\x00\x00fooq\x0bK\x01X\x03\x00\x00\x00bar' b'X\x03\x00\x00\x00fooq\x0bK\x01X\x03\x00\x00\x00bar'
b'q\x0cK\x02ubh\ttq\rh\rK\x05e.' b'q\x0cK\x02ubh\ttq\rh\rK\x05e.'
...@@ -267,66 +268,66 @@ DATA1_DIS = """\ ...@@ -267,66 +268,66 @@ DATA1_DIS = """\
4: K BININT1 0 4: K BININT1 0
6: K BININT1 1 6: K BININT1 1
8: G BINFLOAT 2.0 8: G BINFLOAT 2.0
17: c GLOBAL 'builtins complex' 17: c GLOBAL '__builtin__ complex'
35: q BINPUT 1 38: q BINPUT 1
37: ( MARK 40: ( MARK
38: G BINFLOAT 3.0 41: G BINFLOAT 3.0
47: G BINFLOAT 0.0 50: G BINFLOAT 0.0
56: t TUPLE (MARK at 37) 59: t TUPLE (MARK at 40)
57: q BINPUT 2 60: q BINPUT 2
59: R REDUCE 62: R REDUCE
60: q BINPUT 3 63: q BINPUT 3
62: K BININT1 1 65: K BININT1 1
64: J BININT -1 67: J BININT -1
69: K BININT1 255 72: K BININT1 255
71: J BININT -255 74: J BININT -255
76: J BININT -256 79: J BININT -256
81: M BININT2 65535 84: M BININT2 65535
84: J BININT -65535 87: J BININT -65535
89: J BININT -65536 92: J BININT -65536
94: J BININT 2147483647 97: J BININT 2147483647
99: J BININT -2147483647 102: J BININT -2147483647
104: J BININT -2147483648 107: J BININT -2147483648
109: ( MARK 112: ( MARK
110: X BINUNICODE 'abc' 113: X BINUNICODE 'abc'
118: q BINPUT 4 121: q BINPUT 4
120: h BINGET 4 123: h BINGET 4
122: c GLOBAL 'copyreg _reconstructor' 125: c GLOBAL 'copy_reg _reconstructor'
146: q BINPUT 5 150: q BINPUT 5
148: ( MARK 152: ( MARK
149: c GLOBAL '__main__ C' 153: c GLOBAL '__main__ C'
161: q BINPUT 6 165: q BINPUT 6
163: c GLOBAL 'builtins object' 167: c GLOBAL '__builtin__ object'
180: q BINPUT 7 187: q BINPUT 7
182: N NONE 189: N NONE
183: t TUPLE (MARK at 148) 190: t TUPLE (MARK at 152)
184: q BINPUT 8 191: q BINPUT 8
186: R REDUCE 193: R REDUCE
187: q BINPUT 9 194: q BINPUT 9
189: } EMPTY_DICT 196: } EMPTY_DICT
190: q BINPUT 10 197: q BINPUT 10
192: ( MARK 199: ( MARK
193: X BINUNICODE 'foo' 200: X BINUNICODE 'foo'
201: q BINPUT 11 208: q BINPUT 11
203: K BININT1 1 210: K BININT1 1
205: X BINUNICODE 'bar' 212: X BINUNICODE 'bar'
213: q BINPUT 12 220: q BINPUT 12
215: K BININT1 2 222: K BININT1 2
217: u SETITEMS (MARK at 192) 224: u SETITEMS (MARK at 199)
218: b BUILD 225: b BUILD
219: h BINGET 9 226: h BINGET 9
221: t TUPLE (MARK at 109) 228: t TUPLE (MARK at 112)
222: q BINPUT 13 229: q BINPUT 13
224: h BINGET 13 231: h BINGET 13
226: K BININT1 5 233: K BININT1 5
228: e APPENDS (MARK at 3) 235: e APPENDS (MARK at 3)
229: . STOP 236: . STOP
highest protocol among opcodes = 1 highest protocol among opcodes = 1
""" """
DATA2 = ( DATA2 = (
b'\x80\x02]q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c' b'\x80\x02]q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c'
b'builtins\ncomplex\n' b'__builtin__\ncomplex\n'
b'q\x01G@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00' b'q\x01G@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00'
b'\x86q\x02Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xff' b'\x86q\x02Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xff'
b'J\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff' b'J\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff'
...@@ -346,52 +347,52 @@ DATA2_DIS = """\ ...@@ -346,52 +347,52 @@ DATA2_DIS = """\
6: K BININT1 0 6: K BININT1 0
8: K BININT1 1 8: K BININT1 1
10: G BINFLOAT 2.0 10: G BINFLOAT 2.0
19: c GLOBAL 'builtins complex' 19: c GLOBAL '__builtin__ complex'
37: q BINPUT 1 40: q BINPUT 1
39: G BINFLOAT 3.0 42: G BINFLOAT 3.0
48: G BINFLOAT 0.0 51: G BINFLOAT 0.0
57: \x86 TUPLE2 60: \x86 TUPLE2
58: q BINPUT 2 61: q BINPUT 2
60: R REDUCE 63: R REDUCE
61: q BINPUT 3 64: q BINPUT 3
63: K BININT1 1 66: K BININT1 1
65: J BININT -1 68: J BININT -1
70: K BININT1 255 73: K BININT1 255
72: J BININT -255 75: J BININT -255
77: J BININT -256 80: J BININT -256
82: M BININT2 65535 85: M BININT2 65535
85: J BININT -65535 88: J BININT -65535
90: J BININT -65536 93: J BININT -65536
95: J BININT 2147483647 98: J BININT 2147483647
100: J BININT -2147483647 103: J BININT -2147483647
105: J BININT -2147483648 108: J BININT -2147483648
110: ( MARK 113: ( MARK
111: X BINUNICODE 'abc' 114: X BINUNICODE 'abc'
119: q BINPUT 4 122: q BINPUT 4
121: h BINGET 4 124: h BINGET 4
123: c GLOBAL '__main__ C' 126: c GLOBAL '__main__ C'
135: q BINPUT 5 138: q BINPUT 5
137: ) EMPTY_TUPLE 140: ) EMPTY_TUPLE
138: \x81 NEWOBJ 141: \x81 NEWOBJ
139: q BINPUT 6 142: q BINPUT 6
141: } EMPTY_DICT 144: } EMPTY_DICT
142: q BINPUT 7 145: q BINPUT 7
144: ( MARK 147: ( MARK
145: X BINUNICODE 'foo' 148: X BINUNICODE 'foo'
153: q BINPUT 8 156: q BINPUT 8
155: K BININT1 1 158: K BININT1 1
157: X BINUNICODE 'bar' 160: X BINUNICODE 'bar'
165: q BINPUT 9 168: q BINPUT 9
167: K BININT1 2 170: K BININT1 2
169: u SETITEMS (MARK at 144) 172: u SETITEMS (MARK at 147)
170: b BUILD 173: b BUILD
171: h BINGET 6 174: h BINGET 6
173: t TUPLE (MARK at 110) 176: t TUPLE (MARK at 113)
174: q BINPUT 10 177: q BINPUT 10
176: h BINGET 10 179: h BINGET 10
178: K BININT1 5 181: K BININT1 5
180: e APPENDS (MARK at 5) 183: e APPENDS (MARK at 5)
181: . STOP 184: . STOP
highest protocol among opcodes = 2 highest protocol among opcodes = 2
""" """
...@@ -570,14 +571,14 @@ class AbstractPickleTests(unittest.TestCase): ...@@ -570,14 +571,14 @@ class AbstractPickleTests(unittest.TestCase):
xname = X.__name__.encode('ascii') xname = X.__name__.encode('ascii')
# Protocol 0 (text mode pickle): # Protocol 0 (text mode pickle):
""" """
0: ( MARK 0: ( MARK
1: i INST '__main__ X' (MARK at 0) 1: i INST '__main__ X' (MARK at 0)
15: p PUT 0 13: p PUT 0
18: ( MARK 16: ( MARK
19: d DICT (MARK at 18) 17: d DICT (MARK at 16)
20: p PUT 1 18: p PUT 1
23: b BUILD 21: b BUILD
24: . STOP 22: . STOP
""" """
pickle0 = (b"(i__main__\n" pickle0 = (b"(i__main__\n"
b"X\n" b"X\n"
...@@ -587,15 +588,15 @@ class AbstractPickleTests(unittest.TestCase): ...@@ -587,15 +588,15 @@ class AbstractPickleTests(unittest.TestCase):
# Protocol 1 (binary mode pickle) # Protocol 1 (binary mode pickle)
""" """
0: ( MARK 0: ( MARK
1: c GLOBAL '__main__ X' 1: c GLOBAL '__main__ X'
15: q BINPUT 0 13: q BINPUT 0
17: o OBJ (MARK at 0) 15: o OBJ (MARK at 0)
18: q BINPUT 1 16: q BINPUT 1
20: } EMPTY_DICT 18: } EMPTY_DICT
21: q BINPUT 2 19: q BINPUT 2
23: b BUILD 21: b BUILD
24: . STOP 22: . STOP
""" """
pickle1 = (b'(c__main__\n' pickle1 = (b'(c__main__\n'
b'X\n' b'X\n'
...@@ -604,16 +605,16 @@ class AbstractPickleTests(unittest.TestCase): ...@@ -604,16 +605,16 @@ class AbstractPickleTests(unittest.TestCase):
# Protocol 2 (pickle2 = b'\x80\x02' + pickle1) # Protocol 2 (pickle2 = b'\x80\x02' + pickle1)
""" """
0: \x80 PROTO 2 0: \x80 PROTO 2
2: ( MARK 2: ( MARK
3: c GLOBAL '__main__ X' 3: c GLOBAL '__main__ X'
17: q BINPUT 0 15: q BINPUT 0
19: o OBJ (MARK at 2) 17: o OBJ (MARK at 2)
20: q BINPUT 1 18: q BINPUT 1
22: } EMPTY_DICT 20: } EMPTY_DICT
23: q BINPUT 2 21: q BINPUT 2
25: b BUILD 23: b BUILD
26: . STOP 24: . STOP
""" """
pickle2 = (b'\x80\x02(c__main__\n' pickle2 = (b'\x80\x02(c__main__\n'
b'X\n' b'X\n'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment