From 126d29abf8517dd897372d6ff920c30b3d7a81e8 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 11 Feb 2008 22:57:17 +0000 Subject: [PATCH] Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60734 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60731 | raymond.hettinger | 2008-02-11 19:51:08 +0100 (Mon, 11 Feb 2008) | 1 line No need to register classes that already inherit from ABCs. ........ r60733 | lars.gustaebel | 2008-02-11 20:17:10 +0100 (Mon, 11 Feb 2008) | 2 lines Make sure that xstar headers are read correctly. ........ r60734 | raymond.hettinger | 2008-02-11 21:05:53 +0100 (Mon, 11 Feb 2008) | 1 line Add tests for pickletools.optimize(). ........ --- Lib/pickletools.py | 2 +- Lib/test/test_pickletools.py | 23 ++++++++++++++++++++++- Lib/test/test_tarfile.py | 9 +++++++++ Lib/test/testtar.tar | Bin 264704 -> 272384 bytes 4 files changed, 32 insertions(+), 2 deletions(-) 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 3529bdf0acf5a1db9b1d494fda25422816ca00cc..b5bb46b16e682eb196c2eb4e7b9d3f69db916928 100644 GIT binary patch delta 175 zcmZpeBG7O_prM6v3zO`t>C$JI+^46!VlrkmG&N*U*qrE{!nlY@W*Y~yC<})H6l_;K z#C)G|q5{h@K4!UTXP9`IDvGBIa50BW|If|DIz8hVv()saU5vsU21W+PhQV@@iA9_LGcw97 I(_y{`0BB(^2mk;8 delta 71 zcmZp;AkZ*HprM6v3zO_Crqtx=K+<)3$}1*gRueNr28GRxIVp^bm}ItbFpIKqSQr=> Zm;mv1#Rtsy87C^REaPLATjs@l4*)m|6?p&v