[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Issue tracker housecleaning: SVN-1804

From: Nathan Hartman <hartman.nathan_at_gmail.com>
Date: Sun, 3 Nov 2019 18:16:11 -0500

On Sun, Nov 3, 2019 at 12:56 AM Nathan Hartman <hartman.nathan_at_gmail.com>
wrote:

> On Sat, Nov 2, 2019 at 4:00 AM Yasuhito FUTATSUKI <futatuki_at_poem.co.jp>
> wrote:
>
>> <snip>
>>
>> > finally:
>> > server.quit()
>> > ]]]
>>
>> As I mentioned before (but I couldn't tell what I want, sorry),
>> smtplib.SMTP.quit() can raise exception. If server.quit() in finally
>> block has raised an exception and it isn't caught, it will overwrite
>> the exception raised in try block or re-raised in exception block.
>
>
It seems there's another problem.

Apparently the 'raise .. from' construct is Python 3+. Which means
this breaks the mailer for Python 2.7. I found this when I tested on
Python 2.7 earlier and the script terminated with a syntax error at
'raise MessageSendFailure from detail'.

Which do you think is better:

Remove the 'from detail' and lose the original cause of
MessageSendFailure. MessageSendFailure is meant to be handled and
ignored (possibly only used for outputting additional logging),
allowing the mailer to continue mailing, so this might be acceptable.

Or, alternately:

Check which version of Python is running, use 'from detail' only when
Python 3+.

Thanks,
Nathan

[[[
Index: tools/hook-scripts/mailer/mailer.py
===================================================================
--- tools/hook-scripts/mailer/mailer.py (revision 1869339)
+++ tools/hook-scripts/mailer/mailer.py (working copy)
@@ -325,12 +325,12 @@
     except smtplib.SMTPRecipientsRefused as detail:
       sys.stderr.write("mailer.py: SMTP recipient(s) refused: %s: %s\n"
                            % (self.to_addrs, detail,))
- raise MessageSendFailure from detail
+ raise MessageSendFailure # from detail <-- breaks on Python 2.7 !!!!

     except smtplib.SMTPSenderRefused as detail:
       sys.stderr.write("mailer.py: SMTP sender refused: %s: %s\n"
                            % (self.from_addr, detail,))
- raise MessageSendFailure from detail
+ raise MessageSendFailure # from detail <-- breaks on Python 2.7 !!!!

     except smtplib.SMTPException as detail:
       # All other errors are fatal; this includes:
@@ -339,7 +339,11 @@
       raise

     finally:
- server.quit()
+ try:
+ server.quit()
+ except smtplib.SMTPException as detail:
+ sys.stderr.write("mailer.py: Error occurred during SMTP session
cleanup: %s\n"
+ % (detail,))

 class StandardOutput(OutputBase):
]]]
Received on 2019-11-04 00:16:26 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.