[Email-SIG] fixing the current email module

Barry Warsaw barry at python.org
Thu Oct 8 04:45:35 CEST 2009


On Oct 7, 2009, at 12:23 PM, Matthew Dixon Cowles wrote:

> In my opinion, the email module should never raise an exception as a
> result of working with a malformed message. Though it should
> certainly make the information that a message was malformed available
> for the calling program to check.
>
> That is, I think that it's extremely unlikely that the calling
> program wants to blow up as a result of a malformed message. Very
> probably, it wants to make what sense of the message that it can. The
> number of ways in which a message can be malformed is pretty large
> and just how (and when, as has been mentioned) any particular error
> will cause problems for the module is really a matter that's internal
> to the module. The module's user shouldn't have to say, "Over here I
> have to trap UnicodeErrors and over there I have to trap IndexErrors".

I've said it before: I complete agree with you, at least for parsing.   
The big problem in my experience with Mailman is that you're sort of  
too upside down in the application to do anything about parsing errors  
when they occur except log it and shunt it.  And that's just not very  
helpful.

However, when crafting messages from scratch, I think it /would/ be  
okay to raise exceptions when something is done wrong, because the  
application has more control over the data and is in a position to  
either handle the problem or for the bug to be fixed <wink>.  In this  
case, complaining early is much better than say failing in the  
generator.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 832 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/email-sig/attachments/20091007/c80b3e16/attachment.pgp>


More information about the Email-SIG mailing list