email package and line ending

Manlio Perillo manlio_perilloNO at
Fri Dec 23 10:54:32 CET 2005


The problem is this code:

 >>> import email.Message
 >>> msg = email.Message.Message()
 >>> msg["subject"] = "email bug"
 >>> msg["from"] = "Manlio Perillo"
 >>> print repr(msg.as_string())
'subject: email bug\nfrom: Manlio Perillo\n\n'

Why line ending is '\n' and not '\r\n' ?
RFC 2822 says that the delimiter must(?) be '\r\n'.

The same problem is presente in email.Generator and email.Header (for 
multiline headers).

email.Header has a bug:

this code causes an infinite recursion:

 >>> from email.Header import Header
 >>> h = Header('multiline header', 'iso-8859-1', maxlinelen=4)
 >>> e.encode()

Manlio Perillo

More information about the Python-list mailing list