diff options
author | Tim Peters <tim.peters@gmail.com> | 2003-02-15 03:01:11 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2003-02-15 03:01:11 (GMT) |
commit | 080c88b9126c13d14d2383bee345a41529f14130 (patch) | |
tree | d129410fc4d235b4563257d5c12c43c69c1b5cbb /Lib | |
parent | d2c684f79fc1361442b7849d5a2d05b04988616d (diff) | |
download | cpython-080c88b9126c13d14d2383bee345a41529f14130.zip cpython-080c88b9126c13d14d2383bee345a41529f14130.tar.gz cpython-080c88b9126c13d14d2383bee345a41529f14130.tar.bz2 |
cPickle.c, load_build(): Taught cPickle how to pick apart
the optional proto 2 slot state.
pickle.py, load_build(): CAUTION: Noted that cPickle's
load_build and pickle's load_build really don't do the same
things with the state, and didn't before this patch either.
cPickle never tries to do .update(), and has no backoff if
instance.__dict__ can't be retrieved. There are no tests
that can tell the difference, and part of what cPickle's
load_build() did looked accidental to me, so I don't know
what the true intent is here.
pickletester.py, test_pickle.py: Got rid of the hack for
exempting cPickle from running some of the proto 2 tests.
dictobject.c, PyDict_Next(): documented intended use.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/pickle.py | 4 | ||||
-rw-r--r-- | Lib/test/pickletester.py | 7 | ||||
-rw-r--r-- | Lib/test/test_pickle.py | 3 |
3 files changed, 6 insertions, 8 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index 74748f8..c62bddc 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -1249,6 +1249,10 @@ class Unpickler: # the instance variables. This is a semantic # difference when unpickling in restricted # vs. unrestricted modes. + # Note, however, that cPickle has never tried to do the + # .update() business, and always uses + # PyObject_SetItem(inst.__dict__, key, value) in a + # loop over state.items(). for k, v in state.items(): setattr(inst, k, v) if slotstate: diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index 57e051c..d541194 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -728,12 +728,6 @@ class AbstractPickleTests(unittest.TestCase): self.assertEqual(y.abc, 666) self.assertEqual(x.__dict__, y.__dict__) -# XXX Temporary hack, so long as the C implementation of pickle protocol -# XXX 2 isn't ready. When it is, move the methods in TempAbstractPickleTests -# XXX into AbstractPickleTests above, and get rid of TempAbstractPickleTests -# XXX along with the references to it in test_pickle.py. -class TempAbstractPickleTests(unittest.TestCase): - def test_newobj_list_slots(self): x = SlotList([1, 2, 3]) x.foo = 42 @@ -745,6 +739,7 @@ class TempAbstractPickleTests(unittest.TestCase): self.assertEqual(x.foo, y.foo) self.assertEqual(x.bar, y.bar) + class MyInt(int): sample = 1 diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index ac2a596..9cfb9b7 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -5,11 +5,10 @@ from cStringIO import StringIO from test import test_support from test.pickletester import AbstractPickleTests -from test.pickletester import TempAbstractPickleTests as XXXTemp from test.pickletester import AbstractPickleModuleTests from test.pickletester import AbstractPersistentPicklerTests -class PickleTests(AbstractPickleTests, AbstractPickleModuleTests, XXXTemp): +class PickleTests(AbstractPickleTests, AbstractPickleModuleTests): def dumps(self, arg, proto=0, fast=0): # Ignore fast |