From e1fbbd222cd875c44b53a0e1c3fd7f0ab2b7145c Mon Sep 17 00:00:00 2001 From: Lincoln Simba Date: Tue, 28 May 2019 13:28:07 +0300 Subject: [PATCH] In python 3, the Exceptions don't have the attribute message. It's been replaced by args. The Exception by itself is a string, and that's what I have decided to use as is. Signed-off-by: Lincoln Simba --- onadata/apps/logger/views.py | 2 +- onadata/apps/sms_support/parser.py | 2 +- onadata/libs/authentication.py | 2 +- onadata/libs/serializers/stats_serializer.py | 4 ++-- onadata/libs/serializers/xform_serializer.py | 2 +- script/i18ntool.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/onadata/apps/logger/views.py b/onadata/apps/logger/views.py index 90addbd640..31b5516315 100644 --- a/onadata/apps/logger/views.py +++ b/onadata/apps/logger/views.py @@ -716,7 +716,7 @@ def form_upload(request, username): else: content = xform['text'] if isinstance(content, Exception): - content = content.message + content = content status = 500 else: status = 400 diff --git a/onadata/apps/sms_support/parser.py b/onadata/apps/sms_support/parser.py index 8f6b6d8742..a6574478a1 100644 --- a/onadata/apps/sms_support/parser.py +++ b/onadata/apps/sms_support/parser.py @@ -129,7 +129,7 @@ def media_value(value, medias): # check that altitude is integer int(geodata[2]) except Exception as e: - raise SMSCastingError(e.message, xlsf_name) + raise SMSCastingError(e, xlsf_name) return " ".join(geodata) elif xlsf_type in MEDIA_TYPES: diff --git a/onadata/libs/authentication.py b/onadata/libs/authentication.py index a338ca6b57..f885004f66 100644 --- a/onadata/libs/authentication.py +++ b/onadata/libs/authentication.py @@ -80,7 +80,7 @@ def authenticate(self, request): raise AuthenticationFailed( _('Invalid username/password')) except (AttributeError, ValueError, DataError) as e: - raise AuthenticationFailed(e.message) + raise AuthenticationFailed(e) def authenticate_header(self, request): response = self.authenticator.build_challenge_response() diff --git a/onadata/libs/serializers/stats_serializer.py b/onadata/libs/serializers/stats_serializer.py index fefda6e32a..186d373161 100644 --- a/onadata/libs/serializers/stats_serializer.py +++ b/onadata/libs/serializers/stats_serializer.py @@ -47,7 +47,7 @@ def to_representation(self, obj): data = get_form_submissions_grouped_by_field( obj, field, name) except ValueError as e: - raise exceptions.ParseError(detail=e.message) + raise exceptions.ParseError(detail=e) else: if data: element = obj.get_survey_element(field) @@ -93,6 +93,6 @@ def to_representation(self, obj): try: data = stats_function(obj, field) except ValueError as e: - raise exceptions.ParseError(detail=e.message) + raise exceptions.ParseError(detail=e) return data diff --git a/onadata/libs/serializers/xform_serializer.py b/onadata/libs/serializers/xform_serializer.py index 733d1ab3e4..452970e0b7 100644 --- a/onadata/libs/serializers/xform_serializer.py +++ b/onadata/libs/serializers/xform_serializer.py @@ -49,7 +49,7 @@ def _create_enketo_url(request, xform): url = enketo_url(form_url, xform.id_string) MetaData.enketo_url(xform, url) except ConnectionError as e: - logging.exception("Connection Error: %s" % e.message) + logging.exception("Connection Error: %s" % e) except EnketoError as e: logging.exception("Enketo Error: %s" % e.message) diff --git a/script/i18ntool.py b/script/i18ntool.py index 8ac227e3f6..fcacfee1d5 100755 --- a/script/i18ntool.py +++ b/script/i18ntool.py @@ -216,7 +216,7 @@ def main(): if lang not in LANGS: raise ValueError(u"Unknown lang code") except ValueError as e: - puts(colored.red(e.message)) + puts(colored.red(e)) usage() except IndexError: lang = None