comparison mercurial/mail.py @ 43172:9145abd8b96d

py3: decode username and password before SMTP login smtplib.SMTP.login() requires str on Python 3. For 'password', we only need to decode when value comes from config as getpass() returns the correct type already.
author Denis Laxalde <denis@laxalde.org>
date Thu, 10 Oct 2019 21:37:12 +0200
parents 54b06bec8914
children 866bd2cf764b
comparison
equal deleted inserted replaced
43171:54b06bec8914 43172:9145abd8b96d
143 if starttls or smtps: 143 if starttls or smtps:
144 ui.note(_(b'(verifying remote certificate)\n')) 144 ui.note(_(b'(verifying remote certificate)\n'))
145 sslutil.validatesocket(s.sock) 145 sslutil.validatesocket(s.sock)
146 username = ui.config(b'smtp', b'username') 146 username = ui.config(b'smtp', b'username')
147 password = ui.config(b'smtp', b'password') 147 password = ui.config(b'smtp', b'password')
148 if username and not password: 148 if username:
149 password = ui.getpass() 149 if password:
150 password = encoding.strfromlocal(password)
151 else:
152 password = ui.getpass()
150 if username and password: 153 if username and password:
151 ui.note(_(b'(authenticating to mail server as %s)\n') % username) 154 ui.note(_(b'(authenticating to mail server as %s)\n') % username)
155 username = encoding.strfromlocal(username)
152 try: 156 try:
153 s.login(username, password) 157 s.login(username, password)
154 except smtplib.SMTPException as inst: 158 except smtplib.SMTPException as inst:
155 raise error.Abort(inst) 159 raise error.Abort(inst)
156 160