comparison mercurial/mail.py @ 25660:328739ea70c3

global: mass rewrite to use modern exception syntax Python 2.6 introduced the "except type as instance" syntax, replacing the "except type, instance" syntax that came before. Python 3 dropped support for the latter syntax. Since we no longer support Python 2.4 or 2.5, we have no need to continue supporting the "except type, instance". This patch mass rewrites the exception syntax to be Python 2.6+ and Python 3 compatible. This patch was produced by running `2to3 -f except -w -n .`.
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 23 Jun 2015 22:20:08 -0700
parents 03af5c2ddf75
children fa3f0301cf91
comparison
equal deleted inserted replaced
25659:d60678a567a9 25660:328739ea70c3
136 if username and password: 136 if username and password:
137 ui.note(_('(authenticating to mail server as %s)\n') % 137 ui.note(_('(authenticating to mail server as %s)\n') %
138 (username)) 138 (username))
139 try: 139 try:
140 s.login(username, password) 140 s.login(username, password)
141 except smtplib.SMTPException, inst: 141 except smtplib.SMTPException as inst:
142 raise util.Abort(inst) 142 raise util.Abort(inst)
143 143
144 def send(sender, recipients, msg): 144 def send(sender, recipients, msg):
145 try: 145 try:
146 return s.sendmail(sender, recipients, msg) 146 return s.sendmail(sender, recipients, msg)
147 except smtplib.SMTPRecipientsRefused, inst: 147 except smtplib.SMTPRecipientsRefused as inst:
148 recipients = [r[1] for r in inst.recipients.values()] 148 recipients = [r[1] for r in inst.recipients.values()]
149 raise util.Abort('\n' + '\n'.join(recipients)) 149 raise util.Abort('\n' + '\n'.join(recipients))
150 except smtplib.SMTPException, inst: 150 except smtplib.SMTPException as inst:
151 raise util.Abort(inst) 151 raise util.Abort(inst)
152 152
153 return send 153 return send
154 154
155 def _sendmail(ui, sender, recipients, msg): 155 def _sendmail(ui, sender, recipients, msg):