Commit message amended: s/does crash/does not crash/. This patch really does not intend to cause crashes :-)
Martin On Wed, 2011-11-16 at 09:41 +0100, Martin Kosek wrote: > Make sure that PublicError does 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 >
>From a08828a62b5f56e769a29d54031ccae09f5ae345 Mon Sep 17 00:00:00 2001 From: Martin Kosek <[email protected]> Date: Wed, 16 Nov 2011 09:22:41 +0100 Subject: [PATCH] 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 --- ipalib/errors.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/ipalib/errors.py b/ipalib/errors.py index 092d558521405736c1c6e573f65aa5682727a757..3434c26be4c0b17fdc515ca70c8d505090939ea1 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)) ) -- 1.7.7.1
_______________________________________________ Freeipa-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/freeipa-devel
