Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
fa310ee3
Commit
fa310ee3
authored
Feb 15, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use pickled data compatible with Python 2 for testing protocols 0-2.
parent
56abe390
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
217 additions
and
216 deletions
+217
-216
Lib/test/pickletester.py
Lib/test/pickletester.py
+217
-216
No files found.
Lib/test/pickletester.py
View file @
fa310ee3
...
...
@@ -144,21 +144,22 @@ def create_dynamic_class(name, bases):
# the object returned by create_data().
DATA0
=
(
b'(lp0
\
n
L0L
\
n
aL1L
\
n
aF2.0
\
n
ac'
b'builtins
\
n
complex
\
n
'
b'p1
\
n
(F3.0
\
n
F0.0
\
n
tp2
\
n
Rp'
b'3
\
n
aL1L
\
n
aL-1L
\
n
aL255L
\
n
aL-'
b'255L
\
n
aL-256L
\
n
aL65535L
\
n
a'
b'L-65535L
\
n
aL-65536L
\
n
aL2'
b'147483647L
\
n
aL-2147483'
b'647L
\
n
aL-2147483648L
\
n
a('
b'Vabc
\
n
p4
\
n
g4
\
n
ccopyreg'
b'
\
n
_reconstructor
\
n
p5
\
n
('
b'c__main__
\
n
C
\
n
p6
\
n
cbu'
b'iltins
\
n
object
\
n
p7
\
n
Nt'
b'p8
\
n
Rp9
\
n
(dp10
\
n
Vfoo
\
n
p1'
b'1
\
n
L1L
\
n
sVbar
\
n
p12
\
n
L2L
\
n
sb'
b'g9
\
n
tp13
\
n
ag13
\
n
aL5L
\
n
a.'
b'(lp0
\
n
L0L
\
n
aL1L
\
n
aF2.0
\
n
'
b'ac__builtin__
\
n
comple'
b'x
\
n
p1
\
n
(F3.0
\
n
F0.0
\
n
tp2
\
n
'
b'Rp3
\
n
aL1L
\
n
aL-1L
\
n
aL255'
b'L
\
n
aL-255L
\
n
aL-256L
\
n
aL'
b'65535L
\
n
aL-65535L
\
n
aL-'
b'65536L
\
n
aL2147483647L'
b'
\
n
aL-2147483647L
\
n
aL-2'
b'147483648L
\
n
a(Vabc
\
n
p4'
b'
\
n
g4
\
n
ccopy_reg
\
n
_recon'
b'structor
\
n
p5
\
n
(c__main'
b'__
\
n
C
\
n
p6
\
n
c__builtin__'
b'
\
n
object
\
n
p7
\
n
Ntp8
\
n
Rp9
\
n
'
b'(dp10
\
n
Vfoo
\
n
p11
\
n
L1L
\
n
s'
b'Vbar
\
n
p12
\
n
L2L
\
n
sbg9
\
n
tp'
b'13
\
n
ag13
\
n
aL5L
\
n
a.'
)
# Disassembly of DATA0
...
...
@@ -172,88 +173,88 @@ DATA0_DIS = """\
14: a APPEND
15: F FLOAT 2.0
20: a APPEND
21: c GLOBAL '
builtins
complex'
39
: p PUT 1
4
2
: ( MARK
4
3
: F FLOAT 3.0
48
: F FLOAT 0.0
5
3: t TUPLE (MARK at 42
)
5
4
: p PUT 2
57
: R REDUCE
58
: p PUT 3
6
1
: a APPEND
6
2
: L LONG 1
6
6
: a APPEND
67
: L LONG -1
7
2
: a APPEND
7
3
: L LONG 255
79
: a APPEND
8
0
: L LONG -255
87
: a APPEND
88
: L LONG -256
9
5
: a APPEND
9
6
: L LONG 65535
10
4
: a APPEND
10
5
: L LONG -65535
11
4
: a APPEND
11
5
: L LONG -65536
12
4
: a APPEND
12
5
: L LONG 2147483647
1
38
: a APPEND
1
39
: L LONG -2147483647
15
3
: a APPEND
15
4
: L LONG -2147483648
1
68
: a APPEND
1
69
: ( MARK
17
0
: V UNICODE 'abc'
17
5
: p PUT 4
1
78
: g GET 4
18
1: c GLOBAL 'copy
reg _reconstructor'
20
5
: p PUT 5
2
08
: ( MARK
2
09
: c GLOBAL '__main__ C'
22
1
: p PUT 6
22
4: c GLOBAL 'builtins
object'
24
1
: p PUT 7
2
44
: N NONE
2
45: t TUPLE (MARK at 208
)
2
46
: p PUT 8
2
49
: R REDUCE
25
0
: p PUT 9
2
53
: ( MARK
2
54: d DICT (MARK at 253
)
2
55
: p PUT 10
2
59
: V UNICODE 'foo'
2
64
: p PUT 11
2
68
: L LONG 1
27
2
: s SETITEM
2
73
: V UNICODE 'bar'
2
78
: p PUT 12
28
2
: L LONG 2
2
86
: s SETITEM
2
87
: b BUILD
2
88
: g GET 9
29
1: t TUPLE (MARK at 169
)
29
2
: p PUT 13
296
: a APPEND
297
: g GET 13
30
1
: a APPEND
30
2
: L LONG 5
3
06
: a APPEND
3
07
: . STOP
21: c GLOBAL '
__builtin__
complex'
42
: p PUT 1
4
5
: ( MARK
4
6
: F FLOAT 3.0
51
: F FLOAT 0.0
5
6: t TUPLE (MARK at 45
)
5
7
: p PUT 2
60
: R REDUCE
61
: p PUT 3
6
4
: a APPEND
6
5
: L LONG 1
6
9
: a APPEND
70
: L LONG -1
7
5
: a APPEND
7
6
: L LONG 255
82
: a APPEND
8
3
: L LONG -255
90
: a APPEND
91
: L LONG -256
9
8
: a APPEND
9
9
: L LONG 65535
10
7
: a APPEND
10
8
: L LONG -65535
11
7
: a APPEND
11
8
: L LONG -65536
12
7
: a APPEND
12
8
: L LONG 2147483647
1
41
: a APPEND
1
42
: L LONG -2147483647
15
6
: a APPEND
15
7
: L LONG -2147483648
1
71
: a APPEND
1
72
: ( MARK
17
3
: V UNICODE 'abc'
17
8
: p PUT 4
1
81
: g GET 4
18
4: c GLOBAL 'copy_
reg _reconstructor'
20
9
: p PUT 5
2
12
: ( MARK
2
13
: c GLOBAL '__main__ C'
22
5
: p PUT 6
22
8: c GLOBAL '__builtin__
object'
24
8
: p PUT 7
2
51
: N NONE
2
52: t TUPLE (MARK at 212
)
2
53
: p PUT 8
2
56
: R REDUCE
25
7
: p PUT 9
2
60
: ( MARK
2
61: d DICT (MARK at 260
)
2
62
: p PUT 10
2
66
: V UNICODE 'foo'
2
71
: p PUT 11
2
75
: L LONG 1
27
9
: s SETITEM
2
80
: V UNICODE 'bar'
2
85
: p PUT 12
28
9
: L LONG 2
2
93
: s SETITEM
2
94
: b BUILD
2
95
: g GET 9
29
8: t TUPLE (MARK at 172
)
29
9
: p PUT 13
303
: a APPEND
304
: g GET 13
30
8
: a APPEND
30
9
: L LONG 5
3
13
: a APPEND
3
14
: . STOP
highest protocol among opcodes = 0
"""
DATA1
=
(
b']q
\
x00
(K
\
x00
K
\
x01
G@
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
c'
b'builtin
s
\
n
complex
\
n
q
\
x01
'
b']q
\
x00
(K
\
x00
K
\
x01
G@
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
c
__
'
b'builtin
__
\
n
complex
\
n
q
\
x01
'
b'(G@
\
x08
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
G
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
t'
b'q
\
x02
Rq
\
x03
K
\
x01
J
\
xff
\
xff
\
xff
\
xff
K
\
xff
J
\
x01
\
xff
\
xff
\
xff
J'
b'
\
x00
\
xff
\
xff
\
xff
M
\
xff
\
xff
J
\
x01
\
x00
\
xff
\
xff
J
\
x00
\
x00
\
xff
\
xff
J
\
xff
\
xff
'
b'
\
xff
\
x7f
J
\
x01
\
x00
\
x00
\
x80
J
\
x00
\
x00
\
x00
\
x80
(X
\
x03
\
x00
\
x00
\
x00
ab'
b'cq
\
x04
h
\
x04
ccopyreg
\
n
_reco'
b'cq
\
x04
h
\
x04
ccopy
_
reg
\
n
_reco'
b'nstructor
\
n
q
\
x05
(c__main'
b'__
\
n
C
\
n
q
\
x06
c
builtins
\
n
'
b'__
\
n
C
\
n
q
\
x06
c
__builtin__
\
n
'
b'object
\
n
q
\
x07
Ntq
\
x08
Rq
\
t
}q
\
n
('
b'X
\
x03
\
x00
\
x00
\
x00
fooq
\
x0b
K
\
x01
X
\
x03
\
x00
\
x00
\
x00
bar'
b'q
\
x0c
K
\
x02
ubh
\
t
tq
\
r
h
\
r
K
\
x05
e.'
...
...
@@ -267,66 +268,66 @@ DATA1_DIS = """\
4: K BININT1 0
6: K BININT1 1
8: G BINFLOAT 2.0
17: c GLOBAL '
builtins
complex'
3
5
: q BINPUT 1
37
: ( MARK
38
: G BINFLOAT 3.0
47
: G BINFLOAT 0.0
5
6: t TUPLE (MARK at 37
)
57
: q BINPUT 2
59
: R REDUCE
6
0
: q BINPUT 3
6
2
: K BININT1 1
6
4
: J BININT -1
69
: K BININT1 255
7
1
: J BININT -255
7
6
: J BININT -256
8
1
: M BININT2 65535
8
4
: J BININT -65535
89
: J BININT -65536
9
4
: J BININT 2147483647
99
: J BININT -2147483647
10
4
: J BININT -2147483648
1
09
: ( MARK
11
0
: X BINUNICODE 'abc'
1
18
: q BINPUT 4
12
0
: h BINGET 4
12
2: c GLOBAL 'copy
reg _reconstructor'
1
46
: q BINPUT 5
1
48
: ( MARK
1
49
: c GLOBAL '__main__ C'
16
1
: q BINPUT 6
16
3: c GLOBAL 'builtins
object'
18
0
: q BINPUT 7
18
2
: N NONE
1
83: t TUPLE (MARK at 148
)
1
84
: q BINPUT 8
1
86
: R REDUCE
1
87
: q BINPUT 9
1
89
: } EMPTY_DICT
19
0
: q BINPUT 10
19
2
: ( MARK
193
: X BINUNICODE 'foo'
20
1
: q BINPUT 11
2
03
: K BININT1 1
2
05
: X BINUNICODE 'bar'
2
13
: q BINPUT 12
2
15
: K BININT1 2
2
17: u SETITEMS (MARK at 192
)
2
18
: b BUILD
2
19
: h BINGET 9
22
1: t TUPLE (MARK at 109
)
22
2
: q BINPUT 13
2
24
: h BINGET 13
2
26
: K BININT1 5
2
28
: e APPENDS (MARK at 3)
2
29
: . STOP
17: c GLOBAL '
__builtin__
complex'
3
8
: q BINPUT 1
40
: ( MARK
41
: G BINFLOAT 3.0
50
: G BINFLOAT 0.0
5
9: t TUPLE (MARK at 40
)
60
: q BINPUT 2
62
: R REDUCE
6
3
: q BINPUT 3
6
5
: K BININT1 1
6
7
: J BININT -1
72
: K BININT1 255
7
4
: J BININT -255
7
9
: J BININT -256
8
4
: M BININT2 65535
8
7
: J BININT -65535
92
: J BININT -65536
9
7
: J BININT 2147483647
102
: J BININT -2147483647
10
7
: J BININT -2147483648
1
12
: ( MARK
11
3
: X BINUNICODE 'abc'
1
21
: q BINPUT 4
12
3
: h BINGET 4
12
5: c GLOBAL 'copy_
reg _reconstructor'
1
50
: q BINPUT 5
1
52
: ( MARK
1
53
: c GLOBAL '__main__ C'
16
5
: q BINPUT 6
16
7: c GLOBAL '__builtin__
object'
18
7
: q BINPUT 7
18
9
: N NONE
1
90: t TUPLE (MARK at 152
)
1
91
: q BINPUT 8
1
93
: R REDUCE
1
94
: q BINPUT 9
1
96
: } EMPTY_DICT
19
7
: q BINPUT 10
19
9
: ( MARK
200
: X BINUNICODE 'foo'
20
8
: q BINPUT 11
2
10
: K BININT1 1
2
12
: X BINUNICODE 'bar'
2
20
: q BINPUT 12
2
22
: K BININT1 2
2
24: u SETITEMS (MARK at 199
)
2
25
: b BUILD
2
26
: h BINGET 9
22
8: t TUPLE (MARK at 112
)
22
9
: q BINPUT 13
2
31
: h BINGET 13
2
33
: K BININT1 5
2
35
: e APPENDS (MARK at 3)
2
36
: . STOP
highest protocol among opcodes = 1
"""
DATA2
=
(
b'
\
x80
\
x02
]q
\
x00
(K
\
x00
K
\
x01
G@
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
c'
b'
builtins
\
n
complex
\
n
'
b'
__builtin__
\
n
complex
\
n
'
b'q
\
x01
G@
\
x08
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
G
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
b'
\
x86
q
\
x02
Rq
\
x03
K
\
x01
J
\
xff
\
xff
\
xff
\
xff
K
\
xff
J
\
x01
\
xff
\
xff
\
xff
'
b'J
\
x00
\
xff
\
xff
\
xff
M
\
xff
\
xff
J
\
x01
\
x00
\
xff
\
xff
J
\
x00
\
x00
\
xff
\
xff
J
\
xff
'
...
...
@@ -346,52 +347,52 @@ DATA2_DIS = """\
6: K BININT1 0
8: K BININT1 1
10: G BINFLOAT 2.0
19: c GLOBAL '
builtins
complex'
37
: q BINPUT 1
39
: G BINFLOAT 3.0
48
: G BINFLOAT 0.0
57
:
\
x86
TUPLE2
58
: q BINPUT 2
6
0
: R REDUCE
6
1
: q BINPUT 3
6
3
: K BININT1 1
6
5
: J BININT -1
7
0
: K BININT1 255
7
2
: J BININT -255
77
: J BININT -256
8
2
: M BININT2 65535
8
5
: J BININT -65535
9
0
: J BININT -65536
9
5
: J BININT 2147483647
10
0
: J BININT -2147483647
10
5
: J BININT -2147483648
11
0
: ( MARK
11
1
: X BINUNICODE 'abc'
1
19
: q BINPUT 4
12
1
: h BINGET 4
12
3
: c GLOBAL '__main__ C'
13
5
: q BINPUT 5
1
37
: ) EMPTY_TUPLE
1
38
:
\
x81
NEWOBJ
1
39
: q BINPUT 6
14
1
: } EMPTY_DICT
14
2
: q BINPUT 7
14
4
: ( MARK
14
5
: X BINUNICODE 'foo'
15
3
: q BINPUT 8
15
5
: K BININT1 1
1
57
: X BINUNICODE 'bar'
16
5
: q BINPUT 9
1
67
: K BININT1 2
1
69: u SETITEMS (MARK at 144
)
17
0
: b BUILD
17
1
: h BINGET 6
17
3: t TUPLE (MARK at 110
)
17
4
: q BINPUT 10
17
6
: h BINGET 10
1
78
: K BININT1 5
18
0
: e APPENDS (MARK at 5)
18
1
: . STOP
19: c GLOBAL '
__builtin__
complex'
40
: q BINPUT 1
42
: G BINFLOAT 3.0
51
: G BINFLOAT 0.0
60
:
\
x86
TUPLE2
61
: q BINPUT 2
6
3
: R REDUCE
6
4
: q BINPUT 3
6
6
: K BININT1 1
6
8
: J BININT -1
7
3
: K BININT1 255
7
5
: J BININT -255
80
: J BININT -256
8
5
: M BININT2 65535
8
8
: J BININT -65535
9
3
: J BININT -65536
9
8
: J BININT 2147483647
10
3
: J BININT -2147483647
10
8
: J BININT -2147483648
11
3
: ( MARK
11
4
: X BINUNICODE 'abc'
1
22
: q BINPUT 4
12
4
: h BINGET 4
12
6
: c GLOBAL '__main__ C'
13
8
: q BINPUT 5
1
40
: ) EMPTY_TUPLE
1
41
:
\
x81
NEWOBJ
1
42
: q BINPUT 6
14
4
: } EMPTY_DICT
14
5
: q BINPUT 7
14
7
: ( MARK
14
8
: X BINUNICODE 'foo'
15
6
: q BINPUT 8
15
8
: K BININT1 1
1
60
: X BINUNICODE 'bar'
16
8
: q BINPUT 9
1
70
: K BININT1 2
1
72: u SETITEMS (MARK at 147
)
17
3
: b BUILD
17
4
: h BINGET 6
17
6: t TUPLE (MARK at 113
)
17
7
: q BINPUT 10
17
9
: h BINGET 10
1
81
: K BININT1 5
18
3
: e APPENDS (MARK at 5)
18
4
: . STOP
highest protocol among opcodes = 2
"""
...
...
@@ -570,14 +571,14 @@ class AbstractPickleTests(unittest.TestCase):
xname
=
X
.
__name__
.
encode
(
'ascii'
)
# Protocol 0 (text mode pickle):
"""
0: ( MARK
1: i INST '__main__ X' (MARK at 0)
1
5
: p PUT 0
1
8
: ( MARK
1
9: d DICT (MARK at 18
)
20
: p PUT 1
2
3
: b BUILD
2
4
: . STOP
0: ( MARK
1: i INST '__main__ X' (MARK at 0)
1
3
: p PUT 0
1
6
: ( MARK
1
7: d DICT (MARK at 16
)
18
: p PUT 1
2
1
: b BUILD
2
2
: . STOP
"""
pickle0
=
(
b"(i__main__
\
n
"
b"X
\
n
"
...
...
@@ -587,15 +588,15 @@ class AbstractPickleTests(unittest.TestCase):
# Protocol 1 (binary mode pickle)
"""
0: ( MARK
1: c GLOBAL '__main__ X'
1
5
: q BINPUT 0
1
7
: o OBJ (MARK at 0)
1
8
: q BINPUT 1
20
: } EMPTY_DICT
21
: q BINPUT 2
2
3
: b BUILD
2
4
: . STOP
0: ( MARK
1: c GLOBAL '__main__ X'
1
3
: q BINPUT 0
1
5
: o OBJ (MARK at 0)
1
6
: q BINPUT 1
18
: } EMPTY_DICT
19
: q BINPUT 2
2
1
: b BUILD
2
2
: . STOP
"""
pickle1
=
(
b'(c__main__
\
n
'
b'X
\
n
'
...
...
@@ -604,16 +605,16 @@ class AbstractPickleTests(unittest.TestCase):
# Protocol 2 (pickle2 = b'\x80\x02' + pickle1)
"""
0:
\
x80
PROTO 2
2: ( MARK
3: c GLOBAL '__main__ X'
1
7
: q BINPUT 0
1
9
: o OBJ (MARK at 2)
20
: q BINPUT 1
2
2
: } EMPTY_DICT
2
3
: q BINPUT 2
2
5
: b BUILD
2
6
: . STOP
0:
\
x80
PROTO 2
2: ( MARK
3: c GLOBAL '__main__ X'
1
5
: q BINPUT 0
1
7
: o OBJ (MARK at 2)
18
: q BINPUT 1
2
0
: } EMPTY_DICT
2
1
: q BINPUT 2
2
3
: b BUILD
2
4
: . STOP
"""
pickle2
=
(
b'
\
x80
\
x02
(c__main__
\
n
'
b'X
\
n
'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment