mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
@@ -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))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user