diff options
author | Martin Kosek <mkosek@redhat.com> | 2011-11-16 09:22:41 +0100 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2011-11-16 10:59:55 +0100 |
commit | 151001ac48cfd18e91104a9ddc8d2efcabcc5eeb (patch) | |
tree | c5ed9face6a1ade67d93db59b192207adcfbce0e /ipalib/errors.py | |
parent | 8be0d84a599be48e837d498cec45d08cbccd3a03 (diff) | |
download | freeipa-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/errors.py')
-rw-r--r-- | ipalib/errors.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py index 092d55852..3434c26be 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)) ) |