From d26b66313eb0197aadb7a463ae3bc8b76f504a74 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 29 Nov 2015 16:13:51 +0200 Subject: Got rid of "with" for compatibility test_xpickle with Python 2.5. --- Lib/test/pickletester.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index 96df135..267d3f0 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -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 -- cgit v0.12