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
99603b0c
Commit
99603b0c
authored
Jul 20, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Getting rid of cPickle. Mmm, feels good!
parent
be6fe547
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
38 additions
and
5846 deletions
+38
-5846
Lib/Cookie.py
Lib/Cookie.py
+9
-13
Lib/bsddb/dbtables.py
Lib/bsddb/dbtables.py
+1
-1
Lib/bsddb/test/test_dbtables.py
Lib/bsddb/test/test_dbtables.py
+1
-5
Lib/bsddb/test/test_pickle.py
Lib/bsddb/test/test_pickle.py
+0
-8
Lib/collections.py
Lib/collections.py
+1
-1
Lib/copy_reg.py
Lib/copy_reg.py
+2
-2
Lib/idlelib/rpc.py
Lib/idlelib/rpc.py
+1
-1
Lib/logging/handlers.py
Lib/logging/handlers.py
+1
-4
Lib/pickle.py
Lib/pickle.py
+7
-6
Lib/pickletools.py
Lib/pickletools.py
+4
-6
Lib/test/pickletester.py
Lib/test/pickletester.py
+0
-6
Lib/test/test_bool.py
Lib/test/test_bool.py
+0
-41
Lib/test/test_bytes.py
Lib/test/test_bytes.py
+5
-7
Lib/test/test_cpickle.py
Lib/test/test_cpickle.py
+0
-103
Lib/test/test_descr.py
Lib/test/test_descr.py
+2
-29
Lib/test/test_exceptions.py
Lib/test/test_exceptions.py
+1
-7
Lib/test/test_re.py
Lib/test/test_re.py
+0
-6
Lib/test/test_slice.py
Lib/test/test_slice.py
+1
-1
Lib/test/test_xpickle.py
Lib/test/test_xpickle.py
+0
-44
Lib/trace.py
Lib/trace.py
+1
-5
Modules/cPickle.c
Modules/cPickle.c
+0
-5548
setup.py
setup.py
+1
-2
No files found.
Lib/Cookie.py
View file @
99603b0c
...
...
@@ -149,11 +149,10 @@ the value to a string, when the values are set dictionary-style.
SerialCookie
The SerialCookie expects that all values should be serialized using
cPickle (or pickle, if cPickle isn't available). As a result of
serializing, SerialCookie can save almost any Python object to a
value, and recover the exact same object when the cookie has been
returned. (SerialCookie can yield some strange-looking cookie
values, however.)
pickle. As a result of serializing, SerialCookie can save almost any
Python object to a value, and recover the exact same object when the
cookie has been returned. (SerialCookie can yield some
strange-looking cookie values, however.)
>>> C = Cookie.SerialCookie()
>>> C["number"] = 7
...
...
@@ -162,7 +161,7 @@ values, however.)
7
>>> C["string"].value
'seven'
>>> C.output().replace('p0', 'p1') # Hack for
cPickle/pickle
differences
>>> C.output().replace('p0', 'p1') # Hack for
pickling
differences
'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string="Vseven\\012p1\\012."'
Be warned, however, if SerialCookie cannot de-serialize a value (because
...
...
@@ -173,7 +172,7 @@ SmartCookie
The SmartCookie combines aspects of each of the other two flavors.
When setting a value in a dictionary-fashion, the SmartCookie will
serialize (ala
cP
ickle) the value *if and only if* it isn't a
serialize (ala
p
ickle) the value *if and only if* it isn't a
Python string. String objects are *not* serialized. Similarly,
when the load() method parses out values, it attempts to de-serialize
the value. If it fails, then it fallsback to treating the value
...
...
@@ -212,10 +211,7 @@ Finis.
#
import
string
try
:
from
cPickle
import
dumps
,
loads
except
ImportError
:
from
pickle
import
dumps
,
loads
from
pickle
import
dumps
,
loads
import
re
,
warnings
...
...
@@ -660,7 +656,7 @@ class SimpleCookie(BaseCookie):
class
SerialCookie
(
BaseCookie
):
"""SerialCookie
SerialCookie supports arbitrary objects as cookie values. All
values are serialized (using
cP
ickle) before being sent to the
values are serialized (using
p
ickle) before being sent to the
client. All incoming values are assumed to be valid Pickle
representations. IF AN INCOMING VALUE IS NOT IN A VALID PICKLE
FORMAT, THEN AN EXCEPTION WILL BE RAISED.
...
...
@@ -687,7 +683,7 @@ class SmartCookie(BaseCookie):
"""SmartCookie
SmartCookie supports arbitrary objects as cookie values. If the
object is a string, then it is quoted. If the object is not a
string, however, then SmartCookie will use
cP
ickle to serialize
string, however, then SmartCookie will use
p
ickle to serialize
the object into a string representation.
Note: Large cookie values add overhead because they must be
...
...
Lib/bsddb/dbtables.py
View file @
99603b0c
...
...
@@ -22,7 +22,7 @@ import sys
import
copy
import
xdrlib
import
random
import
cPickle
as
pickle
import
pickle
try
:
# For Pythons w/distutils pybsddb
...
...
Lib/bsddb/test/test_dbtables.py
View file @
99603b0c
...
...
@@ -21,11 +21,7 @@
# $Id$
import
sys
,
os
,
re
try
:
import
cPickle
pickle
=
cPickle
except
ImportError
:
import
pickle
import
pickle
import
tempfile
import
unittest
...
...
Lib/bsddb/test/test_pickle.py
View file @
99603b0c
import
sys
,
os
import
pickle
try
:
import
cPickle
except
ImportError
:
cPickle
=
None
import
unittest
import
glob
...
...
@@ -62,10 +58,6 @@ class pickleTestCase(unittest.TestCase):
def
test01_pickle_DBError
(
self
):
self
.
_base_test_pickle_DBError
(
pickle
=
pickle
)
if
cPickle
:
def
test02_cPickle_DBError
(
self
):
self
.
_base_test_pickle_DBError
(
pickle
=
cPickle
)
#----------------------------------------------------------------------
def
test_suite
():
...
...
Lib/collections.py
View file @
99603b0c
...
...
@@ -58,7 +58,7 @@ def NamedTuple(typename, s):
if
__name__
==
'__main__'
:
# verify that instances are pickable
from
cP
ickle
import
loads
,
dumps
from
p
ickle
import
loads
,
dumps
Point
=
NamedTuple
(
'Point'
,
'x y'
)
p
=
Point
(
x
=
10
,
y
=
20
)
assert
p
==
loads
(
dumps
(
p
))
...
...
Lib/copy_reg.py
View file @
99603b0c
"""Helper to provide extensibility for pickle
/cPickle
.
"""Helper to provide extensibility for pickle.
This is only useful to add pickle support for extension types defined in
C, not for instances of user-defined classes.
...
...
@@ -146,7 +146,7 @@ def _slotnames(cls):
_extension_registry
=
{}
# key -> code
_inverted_registry
=
{}
# code -> key
_extension_cache
=
{}
# code -> object
# Don't ever rebind those names:
cPickle
grabs a reference to them when
# Don't ever rebind those names:
pickling
grabs a reference to them when
# it's initialized, and won't see a rebinding.
def
add_extension
(
module
,
name
,
code
):
...
...
Lib/idlelib/rpc.py
View file @
99603b0c
...
...
@@ -33,7 +33,7 @@ import socket
import
select
import
SocketServer
import
struct
import
cPickle
as
pickle
import
pickle
import
threading
import
Queue
import
traceback
...
...
Lib/logging/handlers.py
View file @
99603b0c
...
...
@@ -28,10 +28,7 @@ To use, simply 'import logging' and log away!
"""
import
sys
,
logging
,
socket
,
os
,
struct
,
time
,
glob
try
:
import
cPickle
as
pickle
except
ImportError
:
import
pickle
import
pickle
from
stat
import
ST_DEV
,
ST_INO
try
:
...
...
Lib/pickle.py
View file @
99603b0c
"""Create portable serialized representations of Python objects.
See module cPickle for a (much) faster implementation.
See module copy_reg for a mechanism for registering custom picklers.
See module pickletools source for extensive comments.
...
...
@@ -48,8 +47,7 @@ compatible_formats = ["1.0", # Original protocol 0
"2.0"
,
# Protocol 2
]
# Old format versions we can read
# Keep in synch with cPickle. This is the highest protocol number we
# know how to read.
# This is the highest protocol number we know how to read.
HIGHEST_PROTOCOL
=
2
# The protocol we write by default. May be less than HIGHEST_PROTOCOL.
...
...
@@ -591,8 +589,6 @@ class Pickler:
dispatch
[
list
]
=
save_list
# Keep in synch with cPickle's BATCHSIZE. Nothing will break if it gets
# out of synch, though.
_BATCHSIZE
=
1000
def
_batch_appends
(
self
,
items
):
...
...
@@ -1090,7 +1086,12 @@ class Unpickler:
stack
=
self
.
stack
args
=
stack
.
pop
()
func
=
stack
[
-
1
]
value
=
func
(
*
args
)
try
:
value
=
func
(
*
args
)
except
:
print
(
sys
.
exc_info
())
print
(
func
,
args
)
raise
stack
[
-
1
]
=
value
dispatch
[
REDUCE
[
0
]]
=
load_reduce
...
...
Lib/pickletools.py
View file @
99603b0c
...
...
@@ -597,7 +597,7 @@ float8 = ArgumentDescriptor(
doc
=
"""An 8-byte binary representation of a float, big-endian.
The format is unique to Python, and shared with the struct
module (format string '>d') "in theory" (the struct and
cP
ickle
module (format string '>d') "in theory" (the struct and
p
ickle
implementations don't share the code -- they should). It's
strongly related to the IEEE-754 double format, and, in normal
cases, is in fact identical to the big-endian 754 double format.
...
...
@@ -1587,9 +1587,8 @@ opcodes = [
first insists that the class object have a __safe_for_unpickling__
attribute. Unlike as for the __safe_for_unpickling__ check in REDUCE,
it doesn't matter whether this attribute has a true or false value, it
only matters whether it exists (XXX this is a bug; cPickle
requires the attribute to be true). If __safe_for_unpickling__
doesn't exist, UnpicklingError is raised.
only matters whether it exists (XXX this is a bug). If
__safe_for_unpickling__ doesn't exist, UnpicklingError is raised.
Else (the class object does have a __safe_for_unpickling__ attr),
the class object obtained from INST's arguments is applied to the
...
...
@@ -1624,8 +1623,7 @@ opcodes = [
As for INST, the remainder of the stack above the markobject is
gathered into an argument tuple, and then the logic seems identical,
except that no __safe_for_unpickling__ check is done (XXX this is
a bug; cPickle does test __safe_for_unpickling__). See INST for
the gory details.
a bug). See INST for the gory details.
NOTE: In Python 2.3, INST and OBJ are identical except for how they
get the class object. That was always the intent; the implementations
...
...
Lib/test/pickletester.py
View file @
99603b0c
import
unittest
import
pickle
try
:
import
cPickle
except
ImportError
:
cPickle
=
None
import
pickletools
import
copy_reg
...
...
@@ -12,8 +8,6 @@ from test.test_support import TestFailed, TESTFN, run_with_locale
# Tests that try a number of pickle protocols should have a
# for proto in protocols:
# kind of outer loop.
if
cPickle
is
not
None
:
assert
pickle
.
HIGHEST_PROTOCOL
==
cPickle
.
HIGHEST_PROTOCOL
==
2
protocols
=
range
(
pickle
.
HIGHEST_PROTOCOL
+
1
)
...
...
Lib/test/test_bool.py
View file @
99603b0c
...
...
@@ -268,34 +268,6 @@ class BoolTest(unittest.TestCase):
self
.
assertIs
(
pickle
.
loads
(
pickle
.
dumps
(
True
,
True
)),
True
)
self
.
assertIs
(
pickle
.
loads
(
pickle
.
dumps
(
False
,
True
)),
False
)
def
test_cpickle
(
self
):
try
:
import
cPickle
except
ImportError
:
return
# Just ignore this if cPickle doesn't exist
self
.
assertIs
(
cPickle
.
loads
(
cPickle
.
dumps
(
True
)),
True
)
self
.
assertIs
(
cPickle
.
loads
(
cPickle
.
dumps
(
False
)),
False
)
self
.
assertIs
(
cPickle
.
loads
(
cPickle
.
dumps
(
True
,
True
)),
True
)
self
.
assertIs
(
cPickle
.
loads
(
cPickle
.
dumps
(
False
,
True
)),
False
)
def
test_mixedpickle
(
self
):
import
pickle
try
:
import
cPickle
except
ImportError
:
return
# Just ignore this if cPickle doesn't exist
self
.
assertIs
(
pickle
.
loads
(
cPickle
.
dumps
(
True
)),
True
)
self
.
assertIs
(
pickle
.
loads
(
cPickle
.
dumps
(
False
)),
False
)
self
.
assertIs
(
pickle
.
loads
(
cPickle
.
dumps
(
True
,
True
)),
True
)
self
.
assertIs
(
pickle
.
loads
(
cPickle
.
dumps
(
False
,
True
)),
False
)
self
.
assertIs
(
cPickle
.
loads
(
pickle
.
dumps
(
True
)),
True
)
self
.
assertIs
(
cPickle
.
loads
(
pickle
.
dumps
(
False
)),
False
)
self
.
assertIs
(
cPickle
.
loads
(
pickle
.
dumps
(
True
,
True
)),
True
)
self
.
assertIs
(
cPickle
.
loads
(
pickle
.
dumps
(
False
,
True
)),
False
)
def
test_picklevalues
(
self
):
# Test for specific backwards-compatible pickle values
import
pickle
...
...
@@ -306,19 +278,6 @@ class BoolTest(unittest.TestCase):
self
.
assertEqual
(
pickle
.
dumps
(
True
,
protocol
=
2
),
b'
\
x80
\
x02
\
x88
.'
)
self
.
assertEqual
(
pickle
.
dumps
(
False
,
protocol
=
2
),
b'
\
x80
\
x02
\
x89
.'
)
def
test_cpicklevalues
(
self
):
# Test for specific backwards-compatible pickle values
try
:
import
cPickle
except
ImportError
:
return
# Just ignore the rest if cPickle doesn't exist
self
.
assertEqual
(
cPickle
.
dumps
(
True
,
protocol
=
0
),
b"I01
\
n
."
)
self
.
assertEqual
(
cPickle
.
dumps
(
False
,
protocol
=
0
),
b"I00
\
n
."
)
self
.
assertEqual
(
cPickle
.
dumps
(
True
,
protocol
=
1
),
b"I01
\
n
."
)
self
.
assertEqual
(
cPickle
.
dumps
(
False
,
protocol
=
1
),
b"I00
\
n
."
)
self
.
assertEqual
(
cPickle
.
dumps
(
True
,
protocol
=
2
),
b'
\
x80
\
x02
\
x88
.'
)
self
.
assertEqual
(
cPickle
.
dumps
(
False
,
protocol
=
2
),
b'
\
x80
\
x02
\
x89
.'
)
def
test_convert_to_bool
(
self
):
# Verify that TypeError occurs when bad things are returned
# from __bool__(). This isn't really a bool test, but
...
...
Lib/test/test_bytes.py
View file @
99603b0c
...
...
@@ -4,7 +4,6 @@ import os
import
re
import
sys
import
pickle
import
cPickle
import
tempfile
import
unittest
import
test.test_support
...
...
@@ -641,12 +640,11 @@ class BytesTest(unittest.TestCase):
self.assertEqual(b.rpartition(b'i'), (b'mississipp', b'i', b''))
def test_pickling(self):
for pm in pickle, cPickle:
for proto in range(pm.HIGHEST_PROTOCOL):
for b in b"", b"
a
", b"
abc
", b"
\
xffab
\
x80
", b"
\
0
\
0
\
377
\
0
\
0
":
ps = pm.dumps(b, proto)
q = pm.loads(ps)
self.assertEqual(b, q)
for proto in range(pickle.HIGHEST_PROTOCOL):
for b in b"", b"
a
", b"
abc
", b"
\
xffab
\
x80
", b"
\
0
\
0
\
377
\
0
\
0
":
ps = pickle.dumps(b, proto)
q = pickle.loads(ps)
self.assertEqual(b, q)
def test_strip(self):
b = b'mississippi'
...
...
Lib/test/test_cpickle.py
deleted
100644 → 0
View file @
be6fe547
import
cPickle
import
unittest
from
cStringIO
import
StringIO
from
test.pickletester
import
AbstractPickleTests
,
AbstractPickleModuleTests
from
test
import
test_support
class
cPickleTests
(
AbstractPickleTests
,
AbstractPickleModuleTests
):
def
setUp
(
self
):
self
.
dumps
=
cPickle
.
dumps
self
.
loads
=
cPickle
.
loads
error
=
cPickle
.
BadPickleGet
module
=
cPickle
class
cPicklePicklerTests
(
AbstractPickleTests
):
def
dumps
(
self
,
arg
,
proto
=
0
):
f
=
StringIO
()
p
=
cPickle
.
Pickler
(
f
,
proto
)
p
.
dump
(
arg
)
f
.
seek
(
0
)
return
f
.
read
()
def
loads
(
self
,
buf
):
f
=
StringIO
(
buf
)
p
=
cPickle
.
Unpickler
(
f
)
return
p
.
load
()
error
=
cPickle
.
BadPickleGet
class
cPickleListPicklerTests
(
AbstractPickleTests
):
def
dumps
(
self
,
arg
,
proto
=
0
):
p
=
cPickle
.
Pickler
(
proto
)
p
.
dump
(
arg
)
return
p
.
getvalue
()
def
loads
(
self
,
*
args
):
f
=
StringIO
(
args
[
0
])
p
=
cPickle
.
Unpickler
(
f
)
return
p
.
load
()
error
=
cPickle
.
BadPickleGet
class
cPickleFastPicklerTests
(
AbstractPickleTests
):
def
dumps
(
self
,
arg
,
proto
=
0
):
f
=
StringIO
()
p
=
cPickle
.
Pickler
(
f
,
proto
)
p
.
fast
=
1
p
.
dump
(
arg
)
f
.
seek
(
0
)
return
f
.
read
()
def
loads
(
self
,
*
args
):
f
=
StringIO
(
args
[
0
])
p
=
cPickle
.
Unpickler
(
f
)
return
p
.
load
()
error
=
cPickle
.
BadPickleGet
def
test_recursive_list
(
self
):
self
.
assertRaises
(
ValueError
,
AbstractPickleTests
.
test_recursive_list
,
self
)
def
test_recursive_inst
(
self
):
self
.
assertRaises
(
ValueError
,
AbstractPickleTests
.
test_recursive_inst
,
self
)
def
test_recursive_dict
(
self
):
self
.
assertRaises
(
ValueError
,
AbstractPickleTests
.
test_recursive_dict
,
self
)
def
test_recursive_multi
(
self
):
self
.
assertRaises
(
ValueError
,
AbstractPickleTests
.
test_recursive_multi
,
self
)
def
test_nonrecursive_deep
(
self
):
# If it's not cyclic, it should pickle OK even if the nesting
# depth exceeds PY_CPICKLE_FAST_LIMIT. That happens to be
# 50 today. Jack Jansen reported stack overflow on Mac OS 9
# at 64.
a
=
[]
for
i
in
range
(
60
):
a
=
[
a
]
b
=
self
.
loads
(
self
.
dumps
(
a
))
self
.
assertEqual
(
a
,
b
)
def
test_main
():
test_support
.
run_unittest
(
cPickleTests
,
cPicklePicklerTests
,
cPickleListPicklerTests
,
cPickleFastPicklerTests
)
if
__name__
==
"__main__"
:
test_main
()
Lib/test/test_descr.py
View file @
99603b0c
...
...
@@ -2807,10 +2807,6 @@ def pickles():
if
verbose
:
print
(
"Testing pickling and copying new-style classes and objects..."
)
import
pickle
try
:
import
cPickle
except
ImportError
:
cPickle
=
None
def
sorteditems
(
d
):
return
sorted
(
d
.
items
())
...
...
@@ -2863,9 +2859,7 @@ def pickles():
class
C4
(
C4classic
,
object
):
# mixed inheritance
pass
for
p
in
pickle
,
cPickle
:
if
p
is
None
:
continue
# cPickle not found -- skip it
for
p
in
[
pickle
]:
for
bin
in
0
,
1
:
if
verbose
:
print
(
p
.
__name__
,
[
"text"
,
"binary"
][
bin
])
...
...
@@ -2925,7 +2919,7 @@ def pickles():
def
pickleslots
():
if
verbose
:
print
(
"Testing pickling of classes with __slots__ ..."
)
import
pickle
,
pickle
as
cPickle
import
pickle
# Pickling of classes with __slots__ but without __getstate__ should fail
# (when using protocols 0 or 1)
global
B
,
C
,
D
,
E
...
...
@@ -2942,24 +2936,12 @@ def pickleslots():
pass
else
:
raise
TestFailed
,
"should fail: pickle C instance - %s"
%
base
try
:
cPickle
.
dumps
(
C
(),
0
)
except
TypeError
:
pass
else
:
raise
TestFailed
,
"should fail: cPickle C instance - %s"
%
base
try
:
pickle
.
dumps
(
C
(),
0
)
except
TypeError
:
pass
else
:
raise
TestFailed
,
"should fail: pickle D instance - %s"
%
base
try
:
cPickle
.
dumps
(
D
(),
0
)
except
TypeError
:
pass
else
:
raise
TestFailed
,
"should fail: cPickle D instance - %s"
%
base
# Give C a nice generic __getstate__ and __setstate__
class
C
(
base
):
__slots__
=
[
'a'
]
...
...
@@ -2984,20 +2966,14 @@ def pickleslots():
x
=
C
()
y
=
pickle
.
loads
(
pickle
.
dumps
(
x
))
vereq
(
hasattr
(
y
,
'a'
),
0
)
y
=
cPickle
.
loads
(
cPickle
.
dumps
(
x
))
vereq
(
hasattr
(
y
,
'a'
),
0
)
x
.
a
=
42
y
=
pickle
.
loads
(
pickle
.
dumps
(
x
))
vereq
(
y
.
a
,
42
)
y
=
cPickle
.
loads
(
cPickle
.
dumps
(
x
))
vereq
(
y
.
a
,
42
)
x
=
D
()
x
.
a
=
42
x
.
b
=
100
y
=
pickle
.
loads
(
pickle
.
dumps
(
x
))
vereq
(
y
.
a
+
y
.
b
,
142
)
y
=
cPickle
.
loads
(
cPickle
.
dumps
(
x
))
vereq
(
y
.
a
+
y
.
b
,
142
)
# A subclass that adds a slot should also work
class
E
(
C
):
__slots__
=
[
'b'
]
...
...
@@ -3007,9 +2983,6 @@ def pickleslots():
y
=
pickle
.
loads
(
pickle
.
dumps
(
x
))
vereq
(
y
.
a
,
x
.
a
)
vereq
(
y
.
b
,
x
.
b
)
y
=
cPickle
.
loads
(
cPickle
.
dumps
(
x
))
vereq
(
y
.
a
,
x
.
a
)
vereq
(
y
.
b
,
x
.
b
)
def
copies
():
if
verbose
:
print
(
"Testing copy.copy() and copy.deepcopy()..."
)
...
...
Lib/test/test_exceptions.py
View file @
99603b0c
...
...
@@ -4,10 +4,6 @@ import os
import
sys
import
unittest
import
pickle
try
:
import
cPickle
except
ImportError
:
cPickle
=
None
from
test.test_support
import
(
TESTFN
,
unlink
,
run_unittest
,
guard_warnings_filter
)
...
...
@@ -299,9 +295,7 @@ class ExceptionTests(unittest.TestCase):
value
,
expected
[
checkArgName
]))
# test for pickling support
for
p
in
pickle
,
cPickle
:
if
p
is
None
:
continue
# cPickle not found -- skip it
for
p
in
[
pickle
]:
for
protocol
in
range
(
p
.
HIGHEST_PROTOCOL
+
1
):
s
=
p
.
dumps
(
e
,
protocol
)
new
=
p
.
loads
(
s
)
...
...
Lib/test/test_re.py
View file @
99603b0c
...
...
@@ -412,12 +412,6 @@ class ReTests(unittest.TestCase):
def test_pickling(self):
import pickle
self.pickle_test(pickle)
try:
import cPickle
except ImportError:
pass # cPickle not found -- skip it
else:
self.pickle_test(cPickle)
# old pickles expect the _compile() reconstructor in sre module
import warnings
with guard_warnings_filter():
...
...
Lib/test/test_slice.py
View file @
99603b0c
...
...
@@ -2,7 +2,7 @@
import
unittest
from
test
import
test_support
from
cP
ickle
import
loads
,
dumps
from
p
ickle
import
loads
,
dumps
import
sys
...
...
Lib/test/test_xpickle.py
deleted
100644 → 0
View file @
be6fe547
# test_pickle dumps and loads pickles via pickle.py.
# test_cpickle does the same, but via the cPickle module.
# This test covers the other two cases, making pickles with one module and
# loading them via the other.
import
pickle
import
cPickle
import
unittest
from
test
import
test_support
from
test.pickletester
import
AbstractPickleTests
class
DumpCPickle_LoadPickle
(
AbstractPickleTests
):
error
=
KeyError
def
dumps
(
self
,
arg
,
proto
=
0
,
fast
=
0
):
# Ignore fast
return
cPickle
.
dumps
(
arg
,
proto
)
def
loads
(
self
,
buf
):
# Ignore fast
return
pickle
.
loads
(
buf
)
class
DumpPickle_LoadCPickle
(
AbstractPickleTests
):
error
=
cPickle
.
BadPickleGet
def
dumps
(
self
,
arg
,
proto
=
0
,
fast
=
0
):
# Ignore fast
return
pickle
.
dumps
(
arg
,
proto
)
def
loads
(
self
,
buf
):
# Ignore fast
return
cPickle
.
loads
(
buf
)
def
test_main
():
test_support
.
run_unittest
(
DumpCPickle_LoadPickle
,
DumpPickle_LoadCPickle
)
if
__name__
==
"__main__"
:
test_main
()
Lib/trace.py
View file @
99603b0c
...
...
@@ -58,11 +58,7 @@ import tokenize
import
types
import
gc
try
:
import
cPickle
pickle
=
cPickle
except
ImportError
:
import
pickle
import
pickle
def
usage
(
outfile
):
outfile
.
write
(
"""Usage: %s [OPTIONS] <file> [ARGS]
...
...
Modules/cPickle.c
deleted
100644 → 0
View file @
be6fe547
This diff is collapsed.
Click to expand it.
setup.py
View file @
99603b0c
...
...
@@ -460,9 +460,8 @@ class PyBuildExt(build_ext):
# Fred Drake's interface to the Python parser
exts.append( Extension('parser', ['parsermodule.c']) )
# cStringIO
and cPickle
# cStringIO
exts.append( Extension('cStringIO', ['cStringIO.c']) )
exts.append( Extension('cPickle', ['cPickle.c']) )
# Memory-mapped files (also works on Win32).
if platform not in ['atheos', 'mac']:
...
...
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