From 98ea84447832f9744a1bc5c3648d89133b2fe3e9 Mon Sep 17 00:00:00 2001 From: gholt Date: Fri, 31 May 2013 13:09:26 +0000 Subject: [PATCH] Replaced .message with str() Change-Id: I9a030b84dafe2b2300e8735052f6f15f34bc7aa7 --- swift/common/bufferedhttp.py | 2 +- swift/obj/server.py | 2 +- swift/proxy/controllers/obj.py | 4 ++-- test/unit/common/test_swob.py | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/swift/common/bufferedhttp.py b/swift/common/bufferedhttp.py index 574cc087db..0a816037dd 100644 --- a/swift/common/bufferedhttp.py +++ b/swift/common/bufferedhttp.py @@ -130,7 +130,7 @@ def http_connect(ipaddr, port, device, partition, method, path, try: path = path.encode("utf-8") except UnicodeError, e: - logging.exception(_('Error encoding to UTF-8: %s'), e.message) + logging.exception(_('Error encoding to UTF-8: %s'), str(e)) path = quote('/' + device + '/' + str(partition) + path) return http_connect_raw( ipaddr, port, method, path, headers, query_string, ssl) diff --git a/swift/obj/server.py b/swift/obj/server.py index 82a99c8e09..a210f02543 100644 --- a/swift/obj/server.py +++ b/swift/obj/server.py @@ -719,7 +719,7 @@ class ObjectController(object): try: fsize = request.message_length() except ValueError as e: - return HTTPBadRequest(body=e.message, request=request, + return HTTPBadRequest(body=str(e), request=request, content_type='text/plain') if self.mount_check and not check_mount(self.devices, device): return HTTPInsufficientStorage(drive=device, request=request) diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index c3a1844d5e..633d9abc41 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -707,10 +707,10 @@ class ObjectController(Controller): ml = req.message_length() except ValueError as e: return HTTPBadRequest(request=req, content_type='text/plain', - body=e.message) + body=str(e)) except AttributeError as e: return HTTPNotImplemented(request=req, content_type='text/plain', - body=e.message) + body=str(e)) if ml is not None and ml > MAX_FILE_SIZE: return HTTPRequestEntityTooLarge(request=req) if 'x-delete-after' in req.headers: diff --git a/test/unit/common/test_swob.py b/test/unit/common/test_swob.py index 2eadd51ccb..6debec18ff 100644 --- a/test/unit/common/test_swob.py +++ b/test/unit/common/test_swob.py @@ -590,7 +590,7 @@ class TestRequest(unittest.TestCase): try: l = req.message_length() except ValueError as e: - self.assertEquals(e.message, "Invalid Content-Length header value") + self.assertEquals(str(e), "Invalid Content-Length header value") else: self.fail("Expected a ValueError raised for 'abc'") @@ -606,7 +606,7 @@ class TestRequest(unittest.TestCase): try: l = req.message_length() except AttributeError as e: - self.assertEquals(e.message, "Unsupported Transfer-Coding header" + self.assertEquals(str(e), "Unsupported Transfer-Coding header" " value specified in Transfer-Encoding header") else: self.fail("Expected an AttributeError raised for 'gzip'") @@ -615,7 +615,7 @@ class TestRequest(unittest.TestCase): try: l = req.message_length() except ValueError as e: - self.assertEquals(e.message, "Invalid Transfer-Encoding header value") + self.assertEquals(str(e), "Invalid Transfer-Encoding header value") else: self.fail("Expected a ValueError raised for 'gzip'") @@ -623,7 +623,7 @@ class TestRequest(unittest.TestCase): try: l = req.message_length() except AttributeError as e: - self.assertEquals(e.message, "Unsupported Transfer-Coding header" + self.assertEquals(str(e), "Unsupported Transfer-Coding header" " value specified in Transfer-Encoding header") else: self.fail("Expected an AttributeError raised for 'gzip,identity'")