diff options
author | Guido van Rossum <guido@python.org> | 2008-03-17 22:56:06 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2008-03-17 22:56:06 +0000 |
commit | f41698169198b32eecd60337a9437ea8c1714380 (patch) | |
tree | c7e6d48433cd32bcb489a4b2100353f2edf42b79 /Lib/test/test_pickle.py | |
parent | 953e4e52c4fb63e501bcbaa97db857de9c159cf5 (diff) | |
download | cpython-git-f41698169198b32eecd60337a9437ea8c1714380.tar.gz |
- A new pickle protocol (protocol 3) is added with explicit support
for bytes. This is the default protocol. It intentionally cannot
be unpickled by Python 2.x.
- When a pickle written by Python 2.x contains an (8-bit) str
instance, this is now decoded to a (Unicode) str instance. The
encoding used to do this defaults to ASCII, but can be overridden
via two new keyword arguments to the Unpickler class. Previously
this would create bytes instances, which is usually wrong: str
instances are often used to pickle attribute names etc., and text is
more common than binary data anyway.
Diffstat (limited to 'Lib/test/test_pickle.py')
-rw-r--r-- | Lib/test/test_pickle.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index aa09a6a5cd..67d83c7c36 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -12,23 +12,19 @@ class PickleTests(AbstractPickleTests, AbstractPickleModuleTests): module = pickle error = KeyError - def dumps(self, arg, proto=0, fast=0): - # Ignore fast + def dumps(self, arg, proto=None): return pickle.dumps(arg, proto) def loads(self, buf): - # Ignore fast return pickle.loads(buf) class PicklerTests(AbstractPickleTests): error = KeyError - def dumps(self, arg, proto=0, fast=0): + def dumps(self, arg, proto=None): f = io.BytesIO() p = pickle.Pickler(f, proto) - if fast: - p.fast = fast p.dump(arg) f.seek(0) return bytes(f.read()) @@ -40,14 +36,12 @@ class PicklerTests(AbstractPickleTests): class PersPicklerTests(AbstractPersistentPicklerTests): - def dumps(self, arg, proto=0, fast=0): + def dumps(self, arg, proto=None): class PersPickler(pickle.Pickler): def persistent_id(subself, obj): return self.persistent_id(obj) f = io.BytesIO() p = PersPickler(f, proto) - if fast: - p.fast = fast p.dump(arg) f.seek(0) return f.read() |