summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2011-11-16 09:22:41 +0100
committerMartin Kosek <mkosek@redhat.com>2011-11-16 10:59:55 +0100
commit151001ac48cfd18e91104a9ddc8d2efcabcc5eeb (patch)
treec5ed9face6a1ade67d93db59b192207adcfbce0e /ipalib
parent8be0d84a599be48e837d498cec45d08cbccd3a03 (diff)
downloadfreeipa-151001ac48cfd18e91104a9ddc8d2efcabcc5eeb.tar.gz
freeipa-151001ac48cfd18e91104a9ddc8d2efcabcc5eeb.tar.xz
freeipa-151001ac48cfd18e91104a9ddc8d2efcabcc5eeb.zip
Let PublicError accept Gettext objects
Make sure that PublicError does not crash when it receives Gettext/NGettext object. Instead of throwing a type error, do the translation to receive the required unicode text. https://fedorahosted.org/freeipa/ticket/2096
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/errors.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index 092d5585..3434c26b 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -102,6 +102,7 @@ current block assignments:
from inspect import isclass
from text import _ as ugettext, ngettext as ungettext
+from text import Gettext, NGettext
from constants import TYPE_ERROR
@@ -268,7 +269,9 @@ class PublicError(StandardError):
else:
self.strerror = self.format % kw
else:
- if type(message) is not unicode:
+ if isinstance(message, (Gettext, NGettext)):
+ message = unicode(message)
+ elif type(message) is not unicode:
raise TypeError(
TYPE_ERROR % ('message', unicode, message, type(message))
)