Implement appropriate __getnewargs__ for all immutable subclassable builtin
types. The special handling for these can now be removed from save_newobj().
Add some testing for this.
Also add support for setting the 'fast' flag on the Python Pickler class,
which suppresses use of the memo.
diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py
index d30e084..8870904 100644
--- a/Lib/test/test_pickle.py
+++ b/Lib/test/test_pickle.py
@@ -11,9 +11,13 @@
class PickleTests(AbstractPickleTests, AbstractPickleModuleTests, XXXTemp):
- def setUp(self):
- self.dumps = pickle.dumps
- self.loads = pickle.loads
+ def dumps(self, arg, proto=0, fast=0):
+ # Ignore fast
+ return pickle.dumps(arg, proto)
+
+ def loads(self, buf):
+ # Ignore fast
+ return pickle.loads(buf)
module = pickle
error = KeyError
@@ -22,9 +26,11 @@
error = KeyError
- def dumps(self, arg, proto=0):
+ def dumps(self, arg, proto=0, fast=0):
f = StringIO()
p = pickle.Pickler(f, proto)
+ if fast:
+ p.fast = fast
p.dump(arg)
f.seek(0)
return f.read()
@@ -36,12 +42,14 @@
class PersPicklerTests(AbstractPersistentPicklerTests):
- def dumps(self, arg, proto=0):
+ def dumps(self, arg, proto=0, fast=0):
class PersPickler(pickle.Pickler):
def persistent_id(subself, obj):
return self.persistent_id(obj)
f = StringIO()
p = PersPickler(f, proto)
+ if fast:
+ p.fast = fast
p.dump(arg)
f.seek(0)
return f.read()