From be73e7939b09490fa17dc283644219f361713b94 Mon Sep 17 00:00:00 2001 From: Vu Cong Tuan Date: Tue, 20 Jun 2017 16:28:34 +0700 Subject: [PATCH] Stop using deprecated 'message' attribute in Exception The 'message' attribute has been deprecated and removed from Python3. For more details, please check: https://www.python.org/dev/peps/pep-0352/ Change-Id: Ib3f142812c66354eadec3e5224f70f3ef8ce0e33 --- designate/central/service.py | 8 +++++--- designate/mdns/xfr.py | 2 +- designate/tests/unit/test_central/test_basic.py | 12 +++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/designate/central/service.py b/designate/central/service.py index d2a65100..f3f81b91 100644 --- a/designate/central/service.py +++ b/designate/central/service.py @@ -2683,7 +2683,8 @@ class Service(service.RPCService, service.Service): except Exception as e: msg = _LE('An undefined error occurred during zone import') LOG.exception(msg) - msg = 'An undefined error occurred. %s' % e.message[:130] + msg = 'An undefined error occurred. %s'\ + % six.text_type(e)[:130] zone_import.message = msg zone_import.status = 'ERROR' @@ -2706,12 +2707,13 @@ class Service(service.RPCService, service.Service): zone_import.message = 'Duplicate zone.' except exceptions.InvalidTTL as e: zone_import.status = 'ERROR' - zone_import.message = e.message + zone_import.message = six.text_type(e) except Exception as e: msg = _LE('An undefined error occurred during zone ' 'import creation') LOG.exception(msg) - msg = 'An undefined error occurred. %s' % e.message[:130] + msg = 'An undefined error occurred. %s'\ + % six.text_type(e)[:130] zone_import.message = msg zone_import.status = 'ERROR' diff --git a/designate/mdns/xfr.py b/designate/mdns/xfr.py index 26ab4553..e6c8bf83 100644 --- a/designate/mdns/xfr.py +++ b/designate/mdns/xfr.py @@ -40,7 +40,7 @@ class XFRMixin(object): dnspython_zone = dnsutils.do_axfr(zone.name, servers, timeout=timeout) except exceptions.XFRFailure as e: - LOG.warning(e.message) + LOG.warning(e) return zone.update(dnsutils.from_dnspython_zone(dnspython_zone)) diff --git a/designate/tests/unit/test_central/test_basic.py b/designate/tests/unit/test_central/test_basic.py index 2d227b4d..5dcb8455 100644 --- a/designate/tests/unit/test_central/test_basic.py +++ b/designate/tests/unit/test_central/test_basic.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. +import six import unittest from mock import Mock @@ -577,7 +578,7 @@ class CentralZoneTestCase(CentralBasic): with testtools.ExpectedException(exceptions.InvalidRecordSetName) as e: self.service._is_valid_recordset_name(self.context, zone, rs_name) - self.assertEqual(e.message, 'Name too long') + self.assertEqual(six.text_type(e), 'Name too long') def test__is_valid_recordset_name_wrong_zone(self): zone = RoObject(name='example.org.') @@ -597,8 +598,7 @@ class CentralZoneTestCase(CentralBasic): ) self.assertEqual( 'CNAME recordsets may not be created at the zone apex', - e.message - ) + six.text_type(e)) def test_is_valid_recordset_placement_failing(self): zone = RoObject(name='example.org.', id='1') @@ -615,8 +615,7 @@ class CentralZoneTestCase(CentralBasic): ) self.assertEqual( 'CNAME recordsets may not share a name with any other records', - e.message - ) + six.text_type(e)) def test_is_valid_recordset_placement_failing_2(self): zone = RoObject(name='example.org.', id='1') @@ -634,8 +633,7 @@ class CentralZoneTestCase(CentralBasic): ) self.assertEqual( 'CNAME recordsets may not share a name with any other records', - e.message - ) + six.text_type(e)) def test_is_valid_recordset_placement(self): zone = RoObject(name='example.org.', id='1')