Index: Lib/test/test_exceptions.py =================================================================== --- Lib/test/test_exceptions.py (revision 46702) +++ Lib/test/test_exceptions.py (working copy) @@ -1,10 +1,13 @@ # Python test set -- part 5, built-in exceptions -from test.test_support import TESTFN, unlink, run_unittest +import os +import pickle +import sys +import unittest import warnings -import sys, traceback, os -import unittest +from test.test_support import TESTFN, unlink, run_unittest + # XXX This is not really enough, each *operation* should be tested! class ExceptionTests(unittest.TestCase): @@ -253,8 +256,6 @@ ) except NameError: pass - import pickle, random - for args in exceptionList: expected = args[-1] try: @@ -274,12 +275,13 @@ (repr(e), checkArgName)) # test for pickling support - new = pickle.loads(pickle.dumps(e, random.randint(0, 2))) - for checkArgName in expected: - self.assertEquals(repr(getattr(e, checkArgName)), - repr(expected[checkArgName]), - 'pickled exception "%s", attribute "%s' % - (repr(e), checkArgName)) + for protocol in (0, 1, 2): + new = pickle.loads(pickle.dumps(e, protocol)) + for checkArgName in expected: + self.assertEquals(repr(getattr(new, checkArgName)), + repr(expected[checkArgName]), + 'pickled "%s", attribute "%s' % + (repr(e), checkArgName)) def testKeywordArgs(self): # test that builtin exception don't take keyword args,