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
7279befc
Commit
7279befc
authored
Nov 29, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #25761: Added more test cases for testing unpickling broken data.
Output raised exception at verbose level 2 (-vv).
parent
c472246d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
210 additions
and
93 deletions
+210
-93
Lib/test/pickletester.py
Lib/test/pickletester.py
+197
-93
Lib/test/test_pickle.py
Lib/test/test_pickle.py
+13
-0
No files found.
Lib/test/pickletester.py
View file @
7279befc
...
@@ -11,8 +11,9 @@ import unittest
...
@@ -11,8 +11,9 @@ import unittest
import
weakref
import
weakref
from
http.cookies
import
SimpleCookie
from
http.cookies
import
SimpleCookie
from
test
import
support
from
test.support
import
(
from
test.support
import
(
TestFailed
,
TESTFN
,
run_with_locale
,
no_tracing
,
captured_stdout
,
TestFailed
,
TESTFN
,
run_with_locale
,
no_tracing
,
_2G
,
_4G
,
bigmemtest
,
_2G
,
_4G
,
bigmemtest
,
)
)
...
@@ -679,6 +680,17 @@ class AbstractUnpickleTests(unittest.TestCase):
...
@@ -679,6 +680,17 @@ class AbstractUnpickleTests(unittest.TestCase):
self
.
assertEqual
(
getattr
(
obj
,
slot
,
None
),
self
.
assertEqual
(
getattr
(
obj
,
slot
,
None
),
getattr
(
objcopy
,
slot
,
None
),
msg
=
msg
)
getattr
(
objcopy
,
slot
,
None
),
msg
=
msg
)
def
check_unpickling_error
(
self
,
errors
,
data
):
with
self
.
subTest
(
data
=
data
),
\
self
.
assertRaises
(
errors
):
try
:
self
.
loads
(
data
)
except
BaseException
as
exc
:
if
support
.
verbose
>
1
:
print
(
'%-32r - %s: %s'
%
(
data
,
exc
.
__class__
.
__name__
,
exc
))
raise
def
test_load_from_data0
(
self
):
def
test_load_from_data0
(
self
):
self
.
assert_is_copy
(
self
.
_testdata
,
self
.
loads
(
DATA0
))
self
.
assert_is_copy
(
self
.
_testdata
,
self
.
loads
(
DATA0
))
...
@@ -759,12 +771,7 @@ class AbstractUnpickleTests(unittest.TestCase):
...
@@ -759,12 +771,7 @@ class AbstractUnpickleTests(unittest.TestCase):
# Try too with a bogus literal.
# Try too with a bogus literal.
data
=
b'I'
+
str
(
maxint64
).
encode
(
"ascii"
)
+
b'JUNK
\
n
.'
data
=
b'I'
+
str
(
maxint64
).
encode
(
"ascii"
)
+
b'JUNK
\
n
.'
self
.
assertRaises
(
ValueError
,
self
.
loads
,
data
)
self
.
check_unpickling_error
(
ValueError
,
data
)
def
test_pop_empty_stack
(
self
):
# Test issue7455
s
=
b'0'
self
.
assertRaises
((
pickle
.
UnpicklingError
,
IndexError
),
self
.
loads
,
s
)
def
test_unpickle_from_2x
(
self
):
def
test_unpickle_from_2x
(
self
):
# Unpickle non-trivial data from Python 2.x.
# Unpickle non-trivial data from Python 2.x.
...
@@ -849,22 +856,22 @@ class AbstractUnpickleTests(unittest.TestCase):
...
@@ -849,22 +856,22 @@ class AbstractUnpickleTests(unittest.TestCase):
def
test_negative_32b_binbytes
(
self
):
def
test_negative_32b_binbytes
(
self
):
# On 32-bit builds, a BINBYTES of 2**31 or more is refused
# On 32-bit builds, a BINBYTES of 2**31 or more is refused
dumped
=
b'
\
x80
\
x03
B
\
xff
\
xff
\
xff
\
xff
xyzq
\
x00
.'
dumped
=
b'
\
x80
\
x03
B
\
xff
\
xff
\
xff
\
xff
xyzq
\
x00
.'
with
self
.
assertRaises
((
pickle
.
UnpicklingError
,
OverflowError
)):
self
.
check_unpickling_error
((
pickle
.
UnpicklingError
,
OverflowError
),
self
.
loads
(
dumped
)
dumped
)
@
requires_32b
@
requires_32b
def
test_negative_32b_binunicode
(
self
):
def
test_negative_32b_binunicode
(
self
):
# On 32-bit builds, a BINUNICODE of 2**31 or more is refused
# On 32-bit builds, a BINUNICODE of 2**31 or more is refused
dumped
=
b'
\
x80
\
x03
X
\
xff
\
xff
\
xff
\
xff
xyzq
\
x00
.'
dumped
=
b'
\
x80
\
x03
X
\
xff
\
xff
\
xff
\
xff
xyzq
\
x00
.'
with
self
.
assertRaises
((
pickle
.
UnpicklingError
,
OverflowError
)):
self
.
check_unpickling_error
((
pickle
.
UnpicklingError
,
OverflowError
),
self
.
loads
(
dumped
)
dumped
)
def
test_short_binunicode
(
self
):
def
test_short_binunicode
(
self
):
dumped
=
b'
\
x80
\
x04
\
x8c
\
x04
\
xe2
\
x82
\
xac
\
x00
.'
dumped
=
b'
\
x80
\
x04
\
x8c
\
x04
\
xe2
\
x82
\
xac
\
x00
.'
self
.
assertEqual
(
self
.
loads
(
dumped
),
'
\
u20ac
\
x00
'
)
self
.
assertEqual
(
self
.
loads
(
dumped
),
'
\
u20ac
\
x00
'
)
def
test_misc_get
(
self
):
def
test_misc_get
(
self
):
self
.
assertRaises
(
KeyError
,
self
.
loads
,
b'g0
\
n
p0'
)
self
.
check_unpickling_error
(
KeyError
,
b'g0
\
n
p0'
)
self
.
assert_is_copy
([(
100
,),
(
100
,)],
self
.
assert_is_copy
([(
100
,),
(
100
,)],
self
.
loads
(
b'((Kdtp0
\
n
h
\
x00
l.))'
))
self
.
loads
(
b'((Kdtp0
\
n
h
\
x00
l.))'
))
...
@@ -879,14 +886,14 @@ class AbstractUnpickleTests(unittest.TestCase):
...
@@ -879,14 +886,14 @@ class AbstractUnpickleTests(unittest.TestCase):
@
requires_32b
@
requires_32b
def
test_large_32b_binbytes8
(
self
):
def
test_large_32b_binbytes8
(
self
):
dumped
=
b'
\
x80
\
x04
\
x8e
\
4
\
0
\
0
\
0
\
1
\
0
\
0
\
0
\
xe2
\
x82
\
xac
\
x00
.'
dumped
=
b'
\
x80
\
x04
\
x8e
\
4
\
0
\
0
\
0
\
1
\
0
\
0
\
0
\
xe2
\
x82
\
xac
\
x00
.'
with
self
.
assertRaises
((
pickle
.
UnpicklingError
,
OverflowError
)):
self
.
check_unpickling_error
((
pickle
.
UnpicklingError
,
OverflowError
),
self
.
loads
(
dumped
)
dumped
)
@
requires_32b
@
requires_32b
def
test_large_32b_binunicode8
(
self
):
def
test_large_32b_binunicode8
(
self
):
dumped
=
b'
\
x80
\
x04
\
x8d
\
4
\
0
\
0
\
0
\
1
\
0
\
0
\
0
\
xe2
\
x82
\
xac
\
x00
.'
dumped
=
b'
\
x80
\
x04
\
x8d
\
4
\
0
\
0
\
0
\
1
\
0
\
0
\
0
\
xe2
\
x82
\
xac
\
x00
.'
with
self
.
assertRaises
((
pickle
.
UnpicklingError
,
OverflowError
)):
self
.
check_unpickling_error
((
pickle
.
UnpicklingError
,
OverflowError
),
self
.
loads
(
dumped
)
dumped
)
def
test_get
(
self
):
def
test_get
(
self
):
pickled
=
b'((lp100000
\
n
g100000
\
n
t.'
pickled
=
b'((lp100000
\
n
g100000
\
n
t.'
...
@@ -915,16 +922,16 @@ class AbstractUnpickleTests(unittest.TestCase):
...
@@ -915,16 +922,16 @@ class AbstractUnpickleTests(unittest.TestCase):
def
test_negative_put
(
self
):
def
test_negative_put
(
self
):
# Issue #12847
# Issue #12847
dumped
=
b'Va
\
n
p-1
\
n
.'
dumped
=
b'Va
\
n
p-1
\
n
.'
self
.
assertRaises
(
ValueError
,
self
.
loads
,
dumped
)
self
.
check_unpickling_error
(
ValueError
,
dumped
)
@
requires_32b
@
requires_32b
def
test_negative_32b_binput
(
self
):
def
test_negative_32b_binput
(
self
):
# Issue #12847
# Issue #12847
dumped
=
b'
\
x80
\
x03
X
\
x01
\
x00
\
x00
\
x00
ar
\
xff
\
xff
\
xff
\
xff
.'
dumped
=
b'
\
x80
\
x03
X
\
x01
\
x00
\
x00
\
x00
ar
\
xff
\
xff
\
xff
\
xff
.'
self
.
assertRaises
(
ValueError
,
self
.
loads
,
dumped
)
self
.
check_unpickling_error
(
ValueError
,
dumped
)
def
test_badly_escaped_string
(
self
):
def
test_badly_escaped_string
(
self
):
self
.
assertRaises
(
ValueError
,
self
.
loads
,
b"S'
\
\
'
\
n
."
)
self
.
check_unpickling_error
(
ValueError
,
b"S'
\
\
'
\
n
."
)
def
test_badly_quoted_string
(
self
):
def
test_badly_quoted_string
(
self
):
# Issue #17710
# Issue #17710
...
@@ -942,7 +949,7 @@ class AbstractUnpickleTests(unittest.TestCase):
...
@@ -942,7 +949,7 @@ class AbstractUnpickleTests(unittest.TestCase):
b'S
\
n
.'
,
b'S
\
n
.'
,
b'S.'
]
b'S.'
]
for
p
in
badpickles
:
for
p
in
badpickles
:
self
.
assertRaises
(
pickle
.
UnpicklingError
,
self
.
loads
,
p
)
self
.
check_unpickling_error
(
pickle
.
UnpicklingError
,
p
)
def
test_correctly_quoted_string
(
self
):
def
test_correctly_quoted_string
(
self
):
goodpickles
=
[(
b"S''
\
n
."
,
''
),
goodpickles
=
[(
b"S''
\
n
."
,
''
),
...
@@ -989,86 +996,183 @@ class AbstractUnpickleTests(unittest.TestCase):
...
@@ -989,86 +996,183 @@ class AbstractUnpickleTests(unittest.TestCase):
def
test_bad_stack
(
self
):
def
test_bad_stack
(
self
):
badpickles
=
[
badpickles
=
[
b'0.'
,
# POP
b'.'
,
# STOP
b'1.'
,
# POP_MARK
b'0'
,
# POP
b'2.'
,
# DUP
b'1'
,
# POP_MARK
# b'(2.', # PyUnpickler doesn't raise
b'2'
,
# DUP
b'R.'
,
# REDUCE
# b'(2', # PyUnpickler doesn't raise
b')R.'
,
b'R'
,
# REDUCE
b'a.'
,
# APPEND
b')R'
,
b'Na.'
,
b'a'
,
# APPEND
b'b.'
,
# BUILD
b'Na'
,
b'Nb.'
,
b'b'
,
# BUILD
b'd.'
,
# DICT
b'Nb'
,
b'e.'
,
# APPENDS
b'd'
,
# DICT
# b'(e.', # PyUnpickler raises AttributeError
b'e'
,
# APPENDS
b'ibuiltins
\
n
list
\
n
.'
,
# INST
# b'(e', # PyUnpickler raises AttributeError
b'l.'
,
# LIST
b'ibuiltins
\
n
list
\
n
'
,
# INST
b'o.'
,
# OBJ
b'l'
,
# LIST
b'(o.'
,
b'o'
,
# OBJ
b'p1
\
n
.'
,
# PUT
b'(o'
,
b'q
\
x00
.'
,
# BINPUT
b'p1
\
n
'
,
# PUT
b'r
\
x00
\
x00
\
x00
\
x00
.'
,
# LONG_BINPUT
b'q
\
x00
'
,
# BINPUT
b's.'
,
# SETITEM
b'r
\
x00
\
x00
\
x00
\
x00
'
,
# LONG_BINPUT
b'Ns.'
,
b's'
,
# SETITEM
b'NNs.'
,
b'Ns'
,
b't.'
,
# TUPLE
b'NNs'
,
b'u.'
,
# SETITEMS
b't'
,
# TUPLE
b'(u.'
,
b'u'
,
# SETITEMS
b'}(Nu.'
,
# b'(u', # PyUnpickler doesn't raise
b'
\
x81
.'
,
# NEWOBJ
b'}(Nu'
,
b')
\
x81
.'
,
b'
\
x81
'
,
# NEWOBJ
b'
\
x85
.'
,
# TUPLE1
b')
\
x81
'
,
b'
\
x86
.'
,
# TUPLE2
b'
\
x85
'
,
# TUPLE1
b'N
\
x86
.'
,
b'
\
x86
'
,
# TUPLE2
b'
\
x87
.'
,
# TUPLE3
b'N
\
x86
'
,
b'N
\
x87
.'
,
b'
\
x87
'
,
# TUPLE3
b'NN
\
x87
.'
,
b'N
\
x87
'
,
b'
\
x90
.'
,
# ADDITEMS
b'NN
\
x87
'
,
# b'(\x90.', # PyUnpickler raises AttributeError
b'
\
x90
'
,
# ADDITEMS
b'
\
x91
.'
,
# FROZENSET
# b'(\x90', # PyUnpickler raises AttributeError
b'
\
x92
.'
,
# NEWOBJ_EX
b'
\
x91
'
,
# FROZENSET
b')}
\
x92
.'
,
b'
\
x92
'
,
# NEWOBJ_EX
b'
\
x93
.'
,
# STACK_GLOBAL
b')}
\
x92
'
,
b'Vlist
\
n
\
x93
.'
,
b'
\
x93
'
,
# STACK_GLOBAL
b'
\
x94
.'
,
# MEMOIZE
b'Vlist
\
n
\
x93
'
,
b'
\
x94
'
,
# MEMOIZE
]
]
for
p
in
badpickles
:
for
p
in
badpickles
:
with
self
.
subTest
(
p
):
self
.
check_unpickling_error
(
self
.
bad_stack_errors
,
p
)
self
.
assertRaises
(
self
.
bad_stack_errors
,
self
.
loads
,
p
)
def
test_bad_mark
(
self
):
def
test_bad_mark
(
self
):
badpickles
=
[
badpickles
=
[
b'cbuiltins
\
n
list
\
n
)(R.'
,
# REDUCE
# b'N(.', # STOP
b'cbuiltins
\
n
list
\
n
()R.'
,
b'N(2'
,
# DUP
b']N(a.'
,
# APPEND
b'cbuiltins
\
n
list
\
n
)(R'
,
# REDUCE
b'cbuiltins
\
n
ValueError
\
n
)R}(b.'
,
# BUILD
b'cbuiltins
\
n
list
\
n
()R'
,
b'cbuiltins
\
n
ValueError
\
n
)R(}b.'
,
b']N(a'
,
# APPEND
b'(Nd.'
,
# DICT
# BUILD
b'}NN(s.'
,
# SETITEM
b'cbuiltins
\
n
ValueError
\
n
)R}(b'
,
b'}N(Ns.'
,
b'cbuiltins
\
n
ValueError
\
n
)R(}b'
,
b'cbuiltins
\
n
list
\
n
)(
\
x81
.'
,
# NEWOBJ
b'(Nd'
,
# DICT
b'cbuiltins
\
n
list
\
n
()
\
x81
.'
,
b'N(p1
\
n
'
,
# PUT
b'N(
\
x85
.'
,
# TUPLE1
b'N(q
\
x00
'
,
# BINPUT
b'NN(
\
x86
.'
,
# TUPLE2
b'N(r
\
x00
\
x00
\
x00
\
x00
'
,
# LONG_BINPUT
b'N(N
\
x86
.'
,
b'}NN(s'
,
# SETITEM
b'NNN(
\
x87
.'
,
# TUPLE3
b'}N(Ns'
,
b'NN(N
\
x87
.'
,
b'}(NNs'
,
b'N(NN
\
x87
.'
,
b'}((u'
,
# SETITEMS
b'cbuiltins
\
n
list
\
n
)}(
\
x92
.'
,
# NEWOBJ_EX
b'cbuiltins
\
n
list
\
n
)(
\
x81
'
,
# NEWOBJ
b'cbuiltins
\
n
list
\
n
)(}
\
x92
.'
,
b'cbuiltins
\
n
list
\
n
()
\
x81
'
,
b'cbuiltins
\
n
list
\
n
()}
\
x92
.'
,
b'N(
\
x85
'
,
# TUPLE1
b'Vbuiltins
\
n
(Vlist
\
n
\
x93
.'
,
# STACK_GLOBAL
b'NN(
\
x86
'
,
# TUPLE2
b'Vbuiltins
\
n
Vlist
\
n
(
\
x93
.'
,
b'N(N
\
x86
'
,
b'NNN(
\
x87
'
,
# TUPLE3
b'NN(N
\
x87
'
,
b'N(NN
\
x87
'
,
b']((
\
x90
'
,
# ADDITEMS
# NEWOBJ_EX
b'cbuiltins
\
n
list
\
n
)}(
\
x92
'
,
b'cbuiltins
\
n
list
\
n
)(}
\
x92
'
,
b'cbuiltins
\
n
list
\
n
()}
\
x92
'
,
# STACK_GLOBAL
b'Vbuiltins
\
n
(Vlist
\
n
\
x93
'
,
b'Vbuiltins
\
n
Vlist
\
n
(
\
x93
'
,
b'N(
\
x94
'
,
# MEMOIZE
]
for
p
in
badpickles
:
self
.
check_unpickling_error
(
self
.
bad_mark_errors
,
p
)
def
test_truncated_data
(
self
):
self
.
check_unpickling_error
(
EOFError
,
b''
)
self
.
check_unpickling_error
(
EOFError
,
b'N'
)
badpickles
=
[
b'B'
,
# BINBYTES
b'B
\
x03
\
x00
\
x00
'
,
b'B
\
x03
\
x00
\
x00
\
x00
'
,
b'B
\
x03
\
x00
\
x00
\
x00
ab'
,
b'C'
,
# SHORT_BINBYTES
b'C
\
x03
'
,
b'C
\
x03
ab'
,
b'F'
,
# FLOAT
b'F0.0'
,
b'F0.00'
,
b'G'
,
# BINFLOAT
b'G
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
,
b'I'
,
# INT
b'I0'
,
b'J'
,
# BININT
b'J
\
x00
\
x00
\
x00
'
,
b'K'
,
# BININT1
b'L'
,
# LONG
b'L0'
,
b'L10'
,
b'L0L'
,
b'L10L'
,
b'M'
,
# BININT2
b'M
\
x00
'
,
# b'P', # PERSID
# b'Pabc',
b'S'
,
# STRING
b"S'abc'"
,
b'T'
,
# BINSTRING
b'T
\
x03
\
x00
\
x00
'
,
b'T
\
x03
\
x00
\
x00
\
x00
'
,
b'T
\
x03
\
x00
\
x00
\
x00
ab'
,
b'U'
,
# SHORT_BINSTRING
b'U
\
x03
'
,
b'U
\
x03
ab'
,
b'V'
,
# UNICODE
b'Vabc'
,
b'X'
,
# BINUNICODE
b'X
\
x03
\
x00
\
x00
'
,
b'X
\
x03
\
x00
\
x00
\
x00
'
,
b'X
\
x03
\
x00
\
x00
\
x00
ab'
,
b'(c'
,
# GLOBAL
b'(cbuiltins'
,
b'(cbuiltins
\
n
'
,
b'(cbuiltins
\
n
list'
,
b'Ng'
,
# GET
b'Ng0'
,
b'(i'
,
# INST
b'(ibuiltins'
,
b'(ibuiltins
\
n
'
,
b'(ibuiltins
\
n
list'
,
b'Nh'
,
# BINGET
b'Nj'
,
# LONG_BINGET
b'Nj
\
x00
\
x00
\
x00
'
,
b'Np'
,
# PUT
b'Np0'
,
b'Nq'
,
# BINPUT
b'Nr'
,
# LONG_BINPUT
b'Nr
\
x00
\
x00
\
x00
'
,
b'
\
x80
'
,
# PROTO
b'
\
x82
'
,
# EXT1
b'
\
x83
'
,
# EXT2
b'
\
x84
\
x01
'
,
b'
\
x84
'
,
# EXT4
b'
\
x84
\
x01
\
x00
\
x00
'
,
b'
\
x8a
'
,
# LONG1
b'
\
x8b
'
,
# LONG4
b'
\
x8b
\
x00
\
x00
\
x00
'
,
b'
\
x8c
'
,
# SHORT_BINUNICODE
b'
\
x8c
\
x03
'
,
b'
\
x8c
\
x03
ab'
,
b'
\
x8d
'
,
# BINUNICODE8
b'
\
x8d
\
x03
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
,
b'
\
x8d
\
x03
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
,
b'
\
x8d
\
x03
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
ab'
,
b'
\
x8e
'
,
# BINBYTES8
b'
\
x8e
\
x03
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
,
b'
\
x8e
\
x03
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
,
b'
\
x8e
\
x03
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
ab'
,
b'
\
x95
'
,
# FRAME
b'
\
x95
\
x02
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
,
b'
\
x95
\
x02
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
,
b'
\
x95
\
x02
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
N'
,
]
]
for
p
in
badpickles
:
for
p
in
badpickles
:
# PyUnpickler prints reduce errors to stdout
self
.
check_unpickling_error
(
self
.
truncated_errors
,
p
)
with
self
.
subTest
(
p
),
captured_stdout
():
try
:
self
.
loads
(
p
)
except
(
IndexError
,
AttributeError
,
TypeError
,
pickle
.
UnpicklingError
):
pass
class
AbstractPickleTests
(
unittest
.
TestCase
):
class
AbstractPickleTests
(
unittest
.
TestCase
):
...
...
Lib/test/test_pickle.py
View file @
7279befc
...
@@ -33,6 +33,11 @@ class PyUnpicklerTests(AbstractUnpickleTests):
...
@@ -33,6 +33,11 @@ class PyUnpicklerTests(AbstractUnpickleTests):
unpickler
=
pickle
.
_Unpickler
unpickler
=
pickle
.
_Unpickler
bad_stack_errors
=
(
IndexError
,)
bad_stack_errors
=
(
IndexError
,)
bad_mark_errors
=
(
IndexError
,
pickle
.
UnpicklingError
,
TypeError
,
AttributeError
,
EOFError
)
truncated_errors
=
(
pickle
.
UnpicklingError
,
EOFError
,
AttributeError
,
ValueError
,
struct
.
error
,
IndexError
,
ImportError
)
def
loads
(
self
,
buf
,
**
kwds
):
def
loads
(
self
,
buf
,
**
kwds
):
f
=
io
.
BytesIO
(
buf
)
f
=
io
.
BytesIO
(
buf
)
...
@@ -64,6 +69,11 @@ class InMemoryPickleTests(AbstractPickleTests, AbstractUnpickleTests,
...
@@ -64,6 +69,11 @@ class InMemoryPickleTests(AbstractPickleTests, AbstractUnpickleTests,
pickler
=
pickle
.
_Pickler
pickler
=
pickle
.
_Pickler
unpickler
=
pickle
.
_Unpickler
unpickler
=
pickle
.
_Unpickler
bad_stack_errors
=
(
pickle
.
UnpicklingError
,
IndexError
)
bad_stack_errors
=
(
pickle
.
UnpicklingError
,
IndexError
)
bad_mark_errors
=
(
pickle
.
UnpicklingError
,
IndexError
,
TypeError
,
AttributeError
,
EOFError
)
truncated_errors
=
(
pickle
.
UnpicklingError
,
EOFError
,
AttributeError
,
ValueError
,
struct
.
error
,
IndexError
,
ImportError
)
def
dumps
(
self
,
arg
,
protocol
=
None
):
def
dumps
(
self
,
arg
,
protocol
=
None
):
return
pickle
.
dumps
(
arg
,
protocol
)
return
pickle
.
dumps
(
arg
,
protocol
)
...
@@ -122,6 +132,9 @@ if has_c_implementation:
...
@@ -122,6 +132,9 @@ if has_c_implementation:
class
CUnpicklerTests
(
PyUnpicklerTests
):
class
CUnpicklerTests
(
PyUnpicklerTests
):
unpickler
=
_pickle
.
Unpickler
unpickler
=
_pickle
.
Unpickler
bad_stack_errors
=
(
pickle
.
UnpicklingError
,)
bad_stack_errors
=
(
pickle
.
UnpicklingError
,)
bad_mark_errors
=
(
EOFError
,)
truncated_errors
=
(
pickle
.
UnpicklingError
,
EOFError
,
AttributeError
,
ValueError
)
class
CPicklerTests
(
PyPicklerTests
):
class
CPicklerTests
(
PyPicklerTests
):
pickler
=
_pickle
.
Pickler
pickler
=
_pickle
.
Pickler
...
...
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