From 6f245db8eacb9bdc1e248b4f6f25e5eb785478c4 Mon Sep 17 00:00:00 2001 From: Stanislav Levin Date: Wed, 20 Jun 2018 12:32:49 +0300 Subject: [PATCH] Fix formatted translations in trust plugin Translation objects have support for format(). This allows to get rid of unicode() which has been removed in Python3. Also some messages to be translated at request time should not use format() Fixes: https://pagure.io/freeipa/issue/7586 Reviewed-By: Alexander Bokovoy --- ipaserver/plugins/trust.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ipaserver/plugins/trust.py b/ipaserver/plugins/trust.py index 91cd1387c..5084b2246 100644 --- a/ipaserver/plugins/trust.py +++ b/ipaserver/plugins/trust.py @@ -559,7 +559,7 @@ class trust(LDAPObject): continue for value in values: if not ipaserver.dcerpc.is_sid_valid(value): - err = unicode(_("invalid SID: {SID}")).format(SID=value) + err = _("invalid SID: {SID}").format(SID=value) raise errors.ValidationError(name=attr, error=err) def get_dn(self, *keys, **kwargs): @@ -685,8 +685,8 @@ ipa idrange-del before retrying the command with the desired range type. StrEnum('range_type?', label=_('Range type'), cli_name='range_type', - doc=(_('Type of trusted domain ID range, one of {vals}' - .format(vals=', '.join(sorted(range_types))))), + doc=_('Type of trusted domain ID range, one of allowed ' + + 'values'), values=sorted(range_types), ), Bool('bidirectional?', @@ -992,9 +992,9 @@ ipa idrange-del before retrying the command with the desired range type. trust_type ) except errors.NotFound: - _message = _("Unable to resolve domain controller for " - "{domain} domain. ") - error_message = unicode(_message).format(domain=keys[-1]) + error_message = _("Unable to resolve domain controller for " + "{domain} domain. " + ).format(domain=keys[-1]) instructions = [] if dns_container_exists(self.obj.backend): @@ -1020,7 +1020,7 @@ ipa idrange-del before retrying the command with the desired range type. "found in the documentation. " ) instructions.append( - unicode(_instruction).format(domain=keys[-1]) + _instruction.format(domain=keys[-1]) ) else: _instruction = _( @@ -1029,7 +1029,7 @@ ipa idrange-del before retrying the command with the desired range type. "domain from IPA hosts and back." ) instructions.append( - unicode(_instruction).format(domain=keys[-1]) + _instruction.format(domain=keys[-1]) ) raise errors.NotFound( reason=error_message,