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
ecced7d0
Commit
ecced7d0
authored
Jun 12, 2008
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert the addition of _pickle because it was causing havok with 64-bit
parent
37943363
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
126 additions
and
4695 deletions
+126
-4695
Lib/pickle.py
Lib/pickle.py
+83
-71
Lib/pickletools.py
Lib/pickletools.py
+10
-12
Lib/test/pickletester.py
Lib/test/pickletester.py
+12
-13
Lib/test/test_pickle.py
Lib/test/test_pickle.py
+19
-34
Lib/test/test_pickletools.py
Lib/test/test_pickletools.py
+2
-0
Misc/NEWS
Misc/NEWS
+0
-4
Modules/_pickle.c
Modules/_pickle.c
+0
-4546
PC/VC6/pythoncore.dsp
PC/VC6/pythoncore.dsp
+0
-4
PC/VS7.1/pythoncore.vcproj
PC/VS7.1/pythoncore.vcproj
+0
-3
PC/VS8.0/pythoncore.vcproj
PC/VS8.0/pythoncore.vcproj
+0
-4
PC/config.c
PC/config.c
+0
-1
setup.py
setup.py
+0
-3
No files found.
Lib/pickle.py
View file @
ecced7d0
This diff is collapsed.
Click to expand it.
Lib/pickletools.py
View file @
ecced7d0
...
...
@@ -2079,12 +2079,11 @@ _dis_test = r"""
70: t TUPLE (MARK at 49)
71: p PUT 5
74: R REDUCE
75: p PUT 6
78: V UNICODE 'def'
83: p PUT 7
86: s SETITEM
87: a APPEND
88: . STOP
75: V UNICODE 'def'
80: p PUT 6
83: s SETITEM
84: a APPEND
85: . STOP
highest protocol among opcodes = 0
Try again with a "binary" pickle.
...
...
@@ -2116,12 +2115,11 @@ Try again with a "binary" pickle.
49: t TUPLE (MARK at 37)
50: q BINPUT 5
52: R REDUCE
53: q BINPUT 6
55: X BINUNICODE 'def'
63: q BINPUT 7
65: s SETITEM
66: e APPENDS (MARK at 3)
67: . STOP
53: X BINUNICODE 'def'
61: q BINPUT 6
63: s SETITEM
64: e APPENDS (MARK at 3)
65: . STOP
highest protocol among opcodes = 1
Exercise the INST/OBJ/BUILD family.
...
...
Lib/test/pickletester.py
View file @
ecced7d0
...
...
@@ -362,7 +362,7 @@ def create_data():
return
x
class
AbstractPickleTests
(
unittest
.
TestCase
):
# Subclass must define self.dumps, self.loads.
# Subclass must define self.dumps, self.loads
, self.error
.
_testdata
=
create_data
()
...
...
@@ -463,9 +463,8 @@ class AbstractPickleTests(unittest.TestCase):
self
.
assertEqual
(
list
(
x
[
0
].
attr
.
keys
()),
[
1
])
self
.
assert_
(
x
[
0
].
attr
[
1
]
is
x
)
def
test_get
(
self
):
self
.
assertRaises
(
KeyError
,
self
.
loads
,
b'g0
\
n
p0'
)
self
.
assertEquals
(
self
.
loads
(
b'((Kdtp0
\
n
h
\
x00
l.))'
),
[(
100
,),
(
100
,)])
def
test_garyp
(
self
):
self
.
assertRaises
(
self
.
error
,
self
.
loads
,
b'garyp'
)
def
test_insecure_strings
(
self
):
# XXX Some of these tests are temporarily disabled
...
...
@@ -956,7 +955,7 @@ class AbstractPickleModuleTests(unittest.TestCase):
f
=
open
(
TESTFN
,
"wb"
)
try
:
f
.
close
()
self
.
assertRaises
(
ValueError
,
pick
le
.
dump
,
123
,
f
)
self
.
assertRaises
(
ValueError
,
self
.
modu
le
.
dump
,
123
,
f
)
finally
:
os
.
remove
(
TESTFN
)
...
...
@@ -965,24 +964,24 @@ class AbstractPickleModuleTests(unittest.TestCase):
f
=
open
(
TESTFN
,
"wb"
)
try
:
f
.
close
()
self
.
assertRaises
(
ValueError
,
pick
le
.
dump
,
123
,
f
)
self
.
assertRaises
(
ValueError
,
self
.
modu
le
.
dump
,
123
,
f
)
finally
:
os
.
remove
(
TESTFN
)
def
test_highest_protocol
(
self
):
# Of course this needs to be changed when HIGHEST_PROTOCOL changes.
self
.
assertEqual
(
pick
le
.
HIGHEST_PROTOCOL
,
3
)
self
.
assertEqual
(
self
.
modu
le
.
HIGHEST_PROTOCOL
,
3
)
def
test_callapi
(
self
):
from
io
import
BytesIO
f
=
BytesIO
()
# With and without keyword arguments
pick
le
.
dump
(
123
,
f
,
-
1
)
pick
le
.
dump
(
123
,
file
=
f
,
protocol
=-
1
)
pick
le
.
dumps
(
123
,
-
1
)
pick
le
.
dumps
(
123
,
protocol
=-
1
)
pick
le
.
Pickler
(
f
,
-
1
)
pick
le
.
Pickler
(
f
,
protocol
=-
1
)
self
.
modu
le
.
dump
(
123
,
f
,
-
1
)
self
.
modu
le
.
dump
(
123
,
file
=
f
,
protocol
=-
1
)
self
.
modu
le
.
dumps
(
123
,
-
1
)
self
.
modu
le
.
dumps
(
123
,
protocol
=-
1
)
self
.
modu
le
.
Pickler
(
f
,
-
1
)
self
.
modu
le
.
Pickler
(
f
,
protocol
=-
1
)
class
AbstractPersistentPicklerTests
(
unittest
.
TestCase
):
...
...
Lib/test/test_pickle.py
View file @
ecced7d0
...
...
@@ -7,42 +7,37 @@ from test.pickletester import AbstractPickleTests
from
test.pickletester
import
AbstractPickleModuleTests
from
test.pickletester
import
AbstractPersistentPicklerTests
try
:
import
_pickle
has_c_implementation
=
True
except
ImportError
:
has_c_implementation
=
False
class
PickleTests
(
AbstractPickleTests
,
AbstractPickleModuleTests
):
module
=
pickle
error
=
KeyError
class
PickleTests
(
AbstractPickleModuleTests
):
pass
def
dumps
(
self
,
arg
,
proto
=
None
):
return
pickle
.
dumps
(
arg
,
proto
)
def
loads
(
self
,
buf
):
return
pickle
.
loads
(
buf
)
class
P
yP
icklerTests
(
AbstractPickleTests
):
class
PicklerTests
(
AbstractPickleTests
):
pickler
=
pickle
.
_Pickler
unpickler
=
pickle
.
_Unpickler
error
=
KeyError
def
dumps
(
self
,
arg
,
proto
=
None
):
f
=
io
.
BytesIO
()
p
=
self
.
p
ickler
(
f
,
proto
)
p
=
pickle
.
P
ickler
(
f
,
proto
)
p
.
dump
(
arg
)
f
.
seek
(
0
)
return
bytes
(
f
.
read
())
def
loads
(
self
,
buf
):
f
=
io
.
BytesIO
(
buf
)
u
=
self
.
u
npickler
(
f
)
u
=
pickle
.
U
npickler
(
f
)
return
u
.
load
()
class
PyPersPicklerTests
(
AbstractPersistentPicklerTests
):
pickler
=
pickle
.
_Pickler
unpickler
=
pickle
.
_Unpickler
class
PersPicklerTests
(
AbstractPersistentPicklerTests
):
def
dumps
(
self
,
arg
,
proto
=
None
):
class
PersPickler
(
self
.
p
ickler
):
class
PersPickler
(
pickle
.
P
ickler
):
def
persistent_id
(
subself
,
obj
):
return
self
.
persistent_id
(
obj
)
f
=
io
.
BytesIO
()
...
...
@@ -52,29 +47,19 @@ class PyPersPicklerTests(AbstractPersistentPicklerTests):
return
f
.
read
()
def
loads
(
self
,
buf
):
class
PersUnpickler
(
self
.
u
npickler
):
class
PersUnpickler
(
pickle
.
U
npickler
):
def
persistent_load
(
subself
,
obj
):
return
self
.
persistent_load
(
obj
)
f
=
io
.
BytesIO
(
buf
)
u
=
PersUnpickler
(
f
)
return
u
.
load
()
if
has_c_implementation
:
class
CPicklerTests
(
PyPicklerTests
):
pickler
=
_pickle
.
Pickler
unpickler
=
_pickle
.
Unpickler
class
CPersPicklerTests
(
PyPersPicklerTests
):
pickler
=
_pickle
.
Pickler
unpickler
=
_pickle
.
Unpickler
def
test_main
():
tests
=
[
PickleTests
,
PyPicklerTests
,
PyPersPicklerTests
]
if
has_c_implementation
:
tests
.
extend
([
CPicklerTests
,
CPersPicklerTests
])
support
.
run_unittest
(
*
tests
)
support
.
run_unittest
(
PickleTests
,
PicklerTests
,
PersPicklerTests
)
support
.
run_doctest
(
pickle
)
if
__name__
==
"__main__"
:
...
...
Lib/test/test_pickletools.py
View file @
ecced7d0
...
...
@@ -12,6 +12,8 @@ class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
def
loads
(
self
,
buf
):
return
pickle
.
loads
(
buf
)
module
=
pickle
error
=
KeyError
def
test_main
():
support
.
run_unittest
(
OptimizedPickleTests
)
...
...
Misc/NEWS
View file @
ecced7d0
...
...
@@ -82,10 +82,6 @@ Library
- Added C optimized implementation of io.StringIO.
- The ``pickle`` module is now automatically use an optimized C
implementation of Pickler and Unpickler when available. The
``cPickle`` module is no longer needed.
- Removed the ``htmllib`` and ``sgmllib`` modules.
- The deprecated ``SmartCookie`` and ``SimpleCookie`` classes have
...
...
Modules/_pickle.c
deleted
100644 → 0
View file @
37943363
This diff is collapsed.
Click to expand it.
PC/VC6/pythoncore.dsp
View file @
ecced7d0
...
...
@@ -145,10 +145,6 @@ SOURCE=..\..\Modules\_stringio.c
# End Source File
# Begin Source File
SOURCE=..\..\Modules\_pickle.c
# End Source File
# Begin Source File
SOURCE=..\..\Modules\_functoolsmodule.c
# End Source File
# Begin Source File
...
...
PC/VS7.1/pythoncore.vcproj
View file @
ecced7d0
...
...
@@ -376,9 +376,6 @@
<File
RelativePath=
"..\..\Modules\_stringio.c"
>
</File>
<File
RelativePath=
"..\..\Modules\_pickle.c"
>
</File>
<File
RelativePath=
"..\..\Modules\_functoolsmodule.c"
>
</File>
...
...
PC/VS8.0/pythoncore.vcproj
View file @
ecced7d0
...
...
@@ -994,10 +994,6 @@
RelativePath=
"..\..\Modules\_stringio.c"
>
</File>
<File
RelativePath=
"..\..\Modules\_pickle.c"
>
</File>
<File
RelativePath=
"..\..\Modules\_functoolsmodule.c"
>
...
...
PC/config.c
View file @
ecced7d0
...
...
@@ -153,7 +153,6 @@ struct _inittab _PyImport_Inittab[] = {
{
"_fileio"
,
PyInit__fileio
},
{
"_bytesio"
,
PyInit__bytesio
},
{
"_stringio"
,
PyInit__stringio
},
{
"_pickle"
,
PyInit__pickle
},
{
"atexit"
,
PyInit_atexit
},
/* Sentinel */
...
...
setup.py
View file @
ecced7d0
...
...
@@ -422,9 +422,6 @@ class PyBuildExt(build_ext):
exts
.
append
(
Extension
(
"_functools"
,
[
"_functoolsmodule.c"
])
)
# Memory-based IO accelerator modules
exts
.
append
(
Extension
(
"_bytesio"
,
[
"_bytesio.c"
])
)
exts
.
append
(
Extension
(
"_stringio"
,
[
"_stringio.c"
])
)
# C-optimized pickle replacement
exts
.
append
(
Extension
(
"_pickle"
,
[
"_pickle.c"
])
)
# atexit
exts
.
append
(
Extension
(
"atexit"
,
[
"atexitmodule.c"
])
)
# _json speedups
...
...
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