From 07401d767a9e1c6afc5ebee64e9a8c7500fad2bc Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 23 Jan 2019 12:44:08 +0000 Subject: [PATCH] issue #477: Python 2.4 type(exc) returns old-style instance. --- mitogen/core.py | 3 ++- tests/call_error_test.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mitogen/core.py b/mitogen/core.py index 859b0689..080c58ef 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -263,7 +263,8 @@ class CallError(Error, object): Error.__init__(self, fmt, *args) else: e = fmt - fmt = '%s.%s: %s' % (type(e).__module__, type(e).__name__, e) + cls = e.__class__ + fmt = '%s.%s: %s' % (cls.__module__, cls.__name__, e) tb = sys.exc_info()[2] if tb: fmt += '\n' diff --git a/tests/call_error_test.py b/tests/call_error_test.py index baebd1eb..72df95b7 100644 --- a/tests/call_error_test.py +++ b/tests/call_error_test.py @@ -31,9 +31,10 @@ class ConstructorTest(testlib.TestCase): def test_form_base_exc(self): ve = SystemExit('eek') e = self.klass(ve) + cls = ve.__class__ self.assertEquals(e.args[0], # varies across 2/3. - '%s.%s: eek' % (type(ve).__module__, type(ve).__name__)) + '%s.%s: eek' % (cls.__module__, cls.__name__)) self.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType)) def test_from_exc_tb(self):