Read about our upcoming Code of Conduct on this issue

Commit e5fba776 authored by Matt Harbison's avatar Matt Harbison
Browse files

Byteify the message argument to `mercurial.i18n._()`

As noted in 4a2d0ce50f5a, it's not intended for _() to convert from unicode, and
it doesn't always work.  For the uses where values are interpolated, they will
not be `None`, given the checks that precede them.
parent 88665ac952a7
......@@ -101,7 +101,7 @@ def import_meu():
import mercurial_extension_utils
except ImportError:
raise error.Abort(_("""Can not import mercurial_extension_utils.
raise error.Abort(_(b"""Can not import mercurial_extension_utils.
Please install this module in Python path.
See Installation chapter in for details
(and for info about TortoiseHG on Windows, or other bundled Python)."""))
......@@ -367,7 +367,7 @@ class HTTPPasswordHandler(object):
auth_user, auth_pwd, keyring_url = self.get_url_config(
ui, parsed_url, actual_user)
if auth_user and actual_user and (actual_user != auth_user):
raise error.Abort(_('keyring: username for %s specified both in repository path (%s) and in .hg/hgrc/[auth] (%s). Please, leave only one of those' % (base_url, actual_user, auth_user)))
raise error.Abort(_(b'keyring: username for %s specified both in repository path (%s) and in .hg/hgrc/[auth] (%s). Please, leave only one of those' % (base_url, actual_user, auth_user)))
if auth_user and auth_pwd:
return auth_user, auth_pwd, self.SRC_CFGAUTH, keyring_url
......@@ -396,7 +396,7 @@ class HTTPPasswordHandler(object):
def prompt_interactively(ui, user, realm, url):
"""Actual interactive prompt"""
if not ui.interactive():
raise error.Abort(_('keyring: http authorization required but program used in non-interactive mode'))
raise error.Abort(_(b'keyring: http authorization required but program used in non-interactive mode'))
if not user:
ui.status(meu.ui_string("keyring: username not specified in hgrc (or in url). Password will not be saved.\n"))
......@@ -655,7 +655,7 @@ def try_smtp_login(ui, smtp_obj, username, password):
if not password:
return False
ui.note(_('(authenticating to mail server as %s)\n') %
ui.note(_(b'(authenticating to mail server as %s)\n') %
smtp_obj.login(username, password)
return True
......@@ -690,10 +690,10 @@ def keyring_supported_smtp(ui, username):
starttls = tls == 'starttls' or parsebool(tls)
smtps = tls == 'smtps'
if (starttls or smtps) and not util.safehasattr(socket, 'ssl'):
raise error.Abort(_("can't use TLS: Python SSL support not installed"))
raise error.Abort(_(b"can't use TLS: Python SSL support not installed"))
mailhost = ui.config('smtp', 'host')
if not mailhost:
raise error.Abort(_(' not configured - cannot send mail'))
raise error.Abort(_(b' not configured - cannot send mail'))
if getattr(sslutil, 'sslkwargs', None) is None:
sslkwargs = None
elif starttls or smtps:
......@@ -701,7 +701,7 @@ def keyring_supported_smtp(ui, username):
sslkwargs = {}
if smtps:
ui.note(_('(using smtps)\n'))
ui.note(_(b'(using smtps)\n'))
# mercurial 3.8 added a mandatory host arg
if not sslkwargs:
......@@ -724,17 +724,17 @@ def keyring_supported_smtp(ui, username):
defaultport = 25
mailport = util.getport(ui.config('smtp', 'port', defaultport))
ui.note(_('sending mail: smtp host %s, port %s\n') %
ui.note(_(b'sending mail: smtp host %s, port %s\n') %
(mailhost, mailport))
s.connect(host=mailhost, port=mailport)
if starttls:
ui.note(_('(using starttls)\n'))
ui.note(_(b'(using starttls)\n'))
if starttls or smtps:
if getattr(sslutil, 'validatesocket', None):
ui.note(_('(verifying remote certificate)\n'))
ui.note(_(b'(verifying remote certificate)\n'))
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
......@@ -743,7 +743,7 @@ def keyring_supported_smtp(ui, username):
# No need to check whether password was found as try_smtp_login
# just returns False if it is absent.
while not try_smtp_login(ui, s, username, password):
password = ui.getpass(_("Password for %s on %s:%d: ") % (username, mailhost, mailport))
password = ui.getpass(_(b"Password for %s on %s:%d: ") % (username, mailhost, mailport))
if stored != password:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment