[Python-checkins] r68257 - in python/branches/release30-maint: Lib/pickle.py
georg.brandl
python-checkins at python.org
Sun Jan 4 00:38:23 CET 2009
Author: georg.brandl
Date: Sun Jan 4 00:38:23 2009
New Revision: 68257
Log:
Merged revisions 67940 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r67940 | alexandre.vassalotti | 2008-12-27 10:30:39 +0100 (Sat, 27 Dec 2008) | 4 lines
Fix issue #4374: Pickle tests fail w/o _pickle extension.
Add an initialization check to mimic the interface of _pickle.
........
Modified:
python/branches/release30-maint/ (props changed)
python/branches/release30-maint/Lib/pickle.py
Modified: python/branches/release30-maint/Lib/pickle.py
==============================================================================
--- python/branches/release30-maint/Lib/pickle.py (original)
+++ python/branches/release30-maint/Lib/pickle.py Sun Jan 4 00:38:23 2009
@@ -222,6 +222,11 @@
def dump(self, obj):
"""Write a pickled representation of obj to the open file."""
+ # Check whether Pickler was initialized correctly. This is
+ # only needed to mimic the behavior of _pickle.Pickler.dump().
+ if not hasattr(self, "write"):
+ raise PicklingError("Pickler.__init__() was not called by "
+ "%s.__init__()" % (self.__class__.__name__,))
if self.proto >= 2:
self.write(PROTO + bytes([self.proto]))
self.save(obj)
@@ -789,6 +794,11 @@
Return the reconstituted object hierarchy specified in the file.
"""
+ # Check whether Unpickler was initialized correctly. This is
+ # only needed to mimic the behavior of _pickle.Unpickler.dump().
+ if not hasattr(self, "read"):
+ raise UnpicklingError("Unpickler.__init__() was not called by "
+ "%s.__init__()" % (self.__class__.__name__,))
self.mark = object() # any new unique object
self.stack = []
self.append = self.stack.append
More information about the Python-checkins
mailing list