Commit ecced7d0 authored by Benjamin Peterson's avatar Benjamin Peterson

revert the addition of _pickle because it was causing havok with 64-bit

parent 37943363
This diff is collapsed.
...@@ -2079,12 +2079,11 @@ _dis_test = r""" ...@@ -2079,12 +2079,11 @@ _dis_test = r"""
70: t TUPLE (MARK at 49) 70: t TUPLE (MARK at 49)
71: p PUT 5 71: p PUT 5
74: R REDUCE 74: R REDUCE
75: p PUT 6 75: V UNICODE 'def'
78: V UNICODE 'def' 80: p PUT 6
83: p PUT 7 83: s SETITEM
86: s SETITEM 84: a APPEND
87: a APPEND 85: . STOP
88: . STOP
highest protocol among opcodes = 0 highest protocol among opcodes = 0
Try again with a "binary" pickle. Try again with a "binary" pickle.
...@@ -2116,12 +2115,11 @@ Try again with a "binary" pickle. ...@@ -2116,12 +2115,11 @@ Try again with a "binary" pickle.
49: t TUPLE (MARK at 37) 49: t TUPLE (MARK at 37)
50: q BINPUT 5 50: q BINPUT 5
52: R REDUCE 52: R REDUCE
53: q BINPUT 6 53: X BINUNICODE 'def'
55: X BINUNICODE 'def' 61: q BINPUT 6
63: q BINPUT 7 63: s SETITEM
65: s SETITEM 64: e APPENDS (MARK at 3)
66: e APPENDS (MARK at 3) 65: . STOP
67: . STOP
highest protocol among opcodes = 1 highest protocol among opcodes = 1
Exercise the INST/OBJ/BUILD family. Exercise the INST/OBJ/BUILD family.
......
...@@ -362,7 +362,7 @@ def create_data(): ...@@ -362,7 +362,7 @@ def create_data():
return x return x
class AbstractPickleTests(unittest.TestCase): class AbstractPickleTests(unittest.TestCase):
# Subclass must define self.dumps, self.loads. # Subclass must define self.dumps, self.loads, self.error.
_testdata = create_data() _testdata = create_data()
...@@ -463,9 +463,8 @@ class AbstractPickleTests(unittest.TestCase): ...@@ -463,9 +463,8 @@ class AbstractPickleTests(unittest.TestCase):
self.assertEqual(list(x[0].attr.keys()), [1]) self.assertEqual(list(x[0].attr.keys()), [1])
self.assert_(x[0].attr[1] is x) self.assert_(x[0].attr[1] is x)
def test_get(self): def test_garyp(self):
self.assertRaises(KeyError, self.loads, b'g0\np0') self.assertRaises(self.error, self.loads, b'garyp')
self.assertEquals(self.loads(b'((Kdtp0\nh\x00l.))'), [(100,), (100,)])
def test_insecure_strings(self): def test_insecure_strings(self):
# XXX Some of these tests are temporarily disabled # XXX Some of these tests are temporarily disabled
...@@ -956,7 +955,7 @@ class AbstractPickleModuleTests(unittest.TestCase): ...@@ -956,7 +955,7 @@ class AbstractPickleModuleTests(unittest.TestCase):
f = open(TESTFN, "wb") f = open(TESTFN, "wb")
try: try:
f.close() f.close()
self.assertRaises(ValueError, pickle.dump, 123, f) self.assertRaises(ValueError, self.module.dump, 123, f)
finally: finally:
os.remove(TESTFN) os.remove(TESTFN)
...@@ -965,24 +964,24 @@ class AbstractPickleModuleTests(unittest.TestCase): ...@@ -965,24 +964,24 @@ class AbstractPickleModuleTests(unittest.TestCase):
f = open(TESTFN, "wb") f = open(TESTFN, "wb")
try: try:
f.close() f.close()
self.assertRaises(ValueError, pickle.dump, 123, f) self.assertRaises(ValueError, self.module.dump, 123, f)
finally: finally:
os.remove(TESTFN) os.remove(TESTFN)
def test_highest_protocol(self): def test_highest_protocol(self):
# Of course this needs to be changed when HIGHEST_PROTOCOL changes. # Of course this needs to be changed when HIGHEST_PROTOCOL changes.
self.assertEqual(pickle.HIGHEST_PROTOCOL, 3) self.assertEqual(self.module.HIGHEST_PROTOCOL, 3)
def test_callapi(self): def test_callapi(self):
from io import BytesIO from io import BytesIO
f = BytesIO() f = BytesIO()
# With and without keyword arguments # With and without keyword arguments
pickle.dump(123, f, -1) self.module.dump(123, f, -1)
pickle.dump(123, file=f, protocol=-1) self.module.dump(123, file=f, protocol=-1)
pickle.dumps(123, -1) self.module.dumps(123, -1)
pickle.dumps(123, protocol=-1) self.module.dumps(123, protocol=-1)
pickle.Pickler(f, -1) self.module.Pickler(f, -1)
pickle.Pickler(f, protocol=-1) self.module.Pickler(f, protocol=-1)
class AbstractPersistentPicklerTests(unittest.TestCase): class AbstractPersistentPicklerTests(unittest.TestCase):
......
...@@ -7,42 +7,37 @@ from test.pickletester import AbstractPickleTests ...@@ -7,42 +7,37 @@ from test.pickletester import AbstractPickleTests
from test.pickletester import AbstractPickleModuleTests from test.pickletester import AbstractPickleModuleTests
from test.pickletester import AbstractPersistentPicklerTests from test.pickletester import AbstractPersistentPicklerTests
try: class PickleTests(AbstractPickleTests, AbstractPickleModuleTests):
import _pickle
has_c_implementation = True
except ImportError:
has_c_implementation = False
module = pickle
error = KeyError
class PickleTests(AbstractPickleModuleTests): def dumps(self, arg, proto=None):
pass return pickle.dumps(arg, proto)
def loads(self, buf):
return pickle.loads(buf)
class PyPicklerTests(AbstractPickleTests): class PicklerTests(AbstractPickleTests):
pickler = pickle._Pickler error = KeyError
unpickler = pickle._Unpickler
def dumps(self, arg, proto=None): def dumps(self, arg, proto=None):
f = io.BytesIO() f = io.BytesIO()
p = self.pickler(f, proto) p = pickle.Pickler(f, proto)
p.dump(arg) p.dump(arg)
f.seek(0) f.seek(0)
return bytes(f.read()) return bytes(f.read())
def loads(self, buf): def loads(self, buf):
f = io.BytesIO(buf) f = io.BytesIO(buf)
u = self.unpickler(f) u = pickle.Unpickler(f)
return u.load() return u.load()
class PersPicklerTests(AbstractPersistentPicklerTests):
class PyPersPicklerTests(AbstractPersistentPicklerTests):
pickler = pickle._Pickler
unpickler = pickle._Unpickler
def dumps(self, arg, proto=None): def dumps(self, arg, proto=None):
class PersPickler(self.pickler): class PersPickler(pickle.Pickler):
def persistent_id(subself, obj): def persistent_id(subself, obj):
return self.persistent_id(obj) return self.persistent_id(obj)
f = io.BytesIO() f = io.BytesIO()
...@@ -52,29 +47,19 @@ class PyPersPicklerTests(AbstractPersistentPicklerTests): ...@@ -52,29 +47,19 @@ class PyPersPicklerTests(AbstractPersistentPicklerTests):
return f.read() return f.read()
def loads(self, buf): def loads(self, buf):
class PersUnpickler(self.unpickler): class PersUnpickler(pickle.Unpickler):
def persistent_load(subself, obj): def persistent_load(subself, obj):
return self.persistent_load(obj) return self.persistent_load(obj)
f = io.BytesIO(buf) f = io.BytesIO(buf)
u = PersUnpickler(f) u = PersUnpickler(f)
return u.load() 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(): def test_main():
tests = [PickleTests, PyPicklerTests, PyPersPicklerTests] support.run_unittest(
if has_c_implementation: PickleTests,
tests.extend([CPicklerTests, CPersPicklerTests]) PicklerTests,
support.run_unittest(*tests) PersPicklerTests
)
support.run_doctest(pickle) support.run_doctest(pickle)
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -12,6 +12,8 @@ class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests): ...@@ -12,6 +12,8 @@ class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
def loads(self, buf): def loads(self, buf):
return pickle.loads(buf) return pickle.loads(buf)
module = pickle
error = KeyError
def test_main(): def test_main():
support.run_unittest(OptimizedPickleTests) support.run_unittest(OptimizedPickleTests)
......
...@@ -82,10 +82,6 @@ Library ...@@ -82,10 +82,6 @@ Library
- Added C optimized implementation of io.StringIO. - 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. - Removed the ``htmllib`` and ``sgmllib`` modules.
- The deprecated ``SmartCookie`` and ``SimpleCookie`` classes have - The deprecated ``SmartCookie`` and ``SimpleCookie`` classes have
......
This diff is collapsed.
...@@ -145,10 +145,6 @@ SOURCE=..\..\Modules\_stringio.c ...@@ -145,10 +145,6 @@ SOURCE=..\..\Modules\_stringio.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\Modules\_pickle.c
# End Source File
# Begin Source File
SOURCE=..\..\Modules\_functoolsmodule.c SOURCE=..\..\Modules\_functoolsmodule.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -376,9 +376,6 @@ ...@@ -376,9 +376,6 @@
<File <File
RelativePath="..\..\Modules\_stringio.c"> RelativePath="..\..\Modules\_stringio.c">
</File> </File>
<File
RelativePath="..\..\Modules\_pickle.c">
</File>
<File <File
RelativePath="..\..\Modules\_functoolsmodule.c"> RelativePath="..\..\Modules\_functoolsmodule.c">
</File> </File>
......
...@@ -994,10 +994,6 @@ ...@@ -994,10 +994,6 @@
RelativePath="..\..\Modules\_stringio.c" RelativePath="..\..\Modules\_stringio.c"
> >
</File> </File>
<File
RelativePath="..\..\Modules\_pickle.c"
>
</File>
<File <File
RelativePath="..\..\Modules\_functoolsmodule.c" RelativePath="..\..\Modules\_functoolsmodule.c"
> >
......
...@@ -153,7 +153,6 @@ struct _inittab _PyImport_Inittab[] = { ...@@ -153,7 +153,6 @@ struct _inittab _PyImport_Inittab[] = {
{"_fileio", PyInit__fileio}, {"_fileio", PyInit__fileio},
{"_bytesio", PyInit__bytesio}, {"_bytesio", PyInit__bytesio},
{"_stringio", PyInit__stringio}, {"_stringio", PyInit__stringio},
{"_pickle", PyInit__pickle},
{"atexit", PyInit_atexit}, {"atexit", PyInit_atexit},
/* Sentinel */ /* Sentinel */
......
...@@ -422,9 +422,6 @@ class PyBuildExt(build_ext): ...@@ -422,9 +422,6 @@ class PyBuildExt(build_ext):
exts.append( Extension("_functools", ["_functoolsmodule.c"]) ) exts.append( Extension("_functools", ["_functoolsmodule.c"]) )
# Memory-based IO accelerator modules # Memory-based IO accelerator modules
exts.append( Extension("_bytesio", ["_bytesio.c"]) ) exts.append( Extension("_bytesio", ["_bytesio.c"]) )
exts.append( Extension("_stringio", ["_stringio.c"]) )
# C-optimized pickle replacement
exts.append( Extension("_pickle", ["_pickle.c"]) )
# atexit # atexit
exts.append( Extension("atexit", ["atexitmodule.c"]) ) exts.append( Extension("atexit", ["atexitmodule.c"]) )
# _json speedups # _json speedups
......
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