diff --git a/Lib/pickletools.py b/Lib/pickletools.py index 1b6967ae463..ca09c03460c 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 2e2fe50b042..3e5b35ab588 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 91cf02469a9..2fbb51e6add 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 3529bdf0acf..b5bb46b16e6 100644 Binary files a/Lib/test/testtar.tar and b/Lib/test/testtar.tar differ