]> granicus.if.org Git - python/commitdiff
Got rid of "with" for compatibility test_xpickle with Python 2.5.
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 29 Nov 2015 14:13:51 +0000 (16:13 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 29 Nov 2015 14:13:51 +0000 (16:13 +0200)
Lib/test/pickletester.py

index 96df135816f0c02ea549d99357173f5525eb0df3..267d3f088e5b8884d3ad674622817bd9902d8f4d 100644 (file)
@@ -476,15 +476,22 @@ class AbstractUnpickleTests(unittest.TestCase):
                                  getattr(objcopy, slot, None), msg=msg)
 
     def check_unpickling_error(self, errors, data):
-        with self.assertRaises(errors):
+        try:
             try:
                 self.loads(data)
             except:
                 if support.verbose > 1:
-                    exc = sys.exc_info()[1]
-                    print('%-32r - %s: %s' %
-                          (data, exc.__class__.__name__, exc))
+                    exc_type, exc, tb = sys.exc_info()
+                    print '%-32r - %s: %s' % (data, exc_type.__name__, exc)
                 raise
+        except errors:
+            pass
+        else:
+            try:
+                exc_name = errors.__name__
+            except AttributeError:
+                exc_name = str(errors)
+            raise self.failureException('%s not raised' % exc_name)
 
     def test_load_from_canned_string(self):
         expected = self._testdata