From bd482284f9a2e55b1415b5276c2f4e402f0ece4e Mon Sep 17 00:00:00 2001 From: Manuel Zaforas Date: Wed, 17 Dec 2014 18:52:50 +0100 Subject: [PATCH] Update exceptions.py Call force_text() only if detail is a string, if detail is other data type better leave raw. The idea is give the programmer the possibility to manage other detail data type when catch the exception --- rest_framework/exceptions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index 1f381e4ef..500c04583 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -39,10 +39,10 @@ class APIException(Exception): default_detail = _('A server error occured') def __init__(self, detail=None): - if detail is not None: - self.detail = force_text(detail) - else: + if detail is None: self.detail = force_text(self.default_detail) + elif isinstance(detail, basestring): + self.detail = force_text(detail) def __str__(self): return self.detail