[Python-checkins] cpython (2.7): Got rid of "with" for compatibility test_xpickle with Python 2.5.

serhiy.storchaka python-checkins at python.org
Sun Nov 29 09:14:12 EST 2015


https://hg.python.org/cpython/rev/2e864db39267
changeset: 99386:2e864db39267
branch: 2.7
parent: 99383:c7e7d77ef8bf
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun Nov 29 16:13:51 2015 +0200
summary:
 Got rid of "with" for compatibility test_xpickle with Python 2.5.
files:
 Lib/test/pickletester.py | 15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -476,15 +476,22 @@
 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
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /