summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/pickletools.py2
-rw-r--r--Lib/test/test_pickletools.py23
-rw-r--r--Lib/test/test_tarfile.py9
-rw-r--r--Lib/test/testtar.tarbin264704 -> 272384 bytes
4 files changed, 32 insertions, 2 deletions
diff --git a/Lib/pickletools.py b/Lib/pickletools.py
index 1b6967a..ca09c03 100644
--- a/Lib/pickletools.py
+++ b/Lib/pickletools.py
@@ -1858,7 +1858,7 @@ def optimize(p):
s.append(p[i:j])
i = stop
s.append(p[i:])
- return ''.join(s)
+ return b''.join(s)
##############################################################################
# A symbolic pickle disassembler.
diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py
index 2e2fe50..3e5b35a 100644
--- a/Lib/test/test_pickletools.py
+++ b/Lib/test/test_pickletools.py
@@ -1,3 +1,24 @@
+import pickle
import pickletools
from test import test_support
-test_support.run_doctest(pickletools)
+from test.pickletester import AbstractPickleTests
+from test.pickletester import AbstractPickleModuleTests
+
+class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
+
+ def dumps(self, arg, proto=0, fast=0):
+ return pickletools.optimize(pickle.dumps(arg, proto))
+
+ def loads(self, buf):
+ return pickle.loads(buf)
+
+ module = pickle
+ error = KeyError
+
+def test_main():
+ test_support.run_unittest(OptimizedPickleTests)
+ test_support.run_doctest(pickletools)
+
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 91cf024..2fbb51e 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -207,6 +207,15 @@ class MiscReadTest(ReadTest):
self.assert_(tarinfo.type == tarfile.DIRTYPE,
"v7 dirtype failed")
+ def test_xstar_type(self):
+ # The xstar format stores extra atime and ctime fields inside the
+ # space reserved for the prefix field. The prefix field must be
+ # ignored in this case, otherwise it will mess up the name.
+ try:
+ self.tar.getmember("misc/regtype-xstar")
+ except KeyError:
+ self.fail("failed to find misc/regtype-xstar (mangled prefix?)")
+
def test_check_members(self):
for tarinfo in self.tar:
self.assert_(int(tarinfo.mtime) == 0o7606136617,
diff --git a/Lib/test/testtar.tar b/Lib/test/testtar.tar
index 3529bdf..b5bb46b 100644
--- a/Lib/test/testtar.tar
+++ b/Lib/test/testtar.tar
Binary files differ