This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add documentation about line endings in email messages.
Type: enhancement Stage: needs patch
Components: email Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: anadelonbrin, barry, r.david.murray, terry.reedy
Priority: low Keywords: easy

Created on 2003-04-20 02:38 by anadelonbrin, last changed 2022-04-10 16:08 by admin.

Messages (4)
msg53862 - (view) Author: Tony Meyer (anadelonbrin) Date: 2003-04-20 02:38
This follows from recent discussion on the spambayes 
mailing list (some of which was also on the mimelib-
devel list) about what character(s) should be used for 
line endings internally and when transmitted.  There is a 
consensus (I think) that the platform/language specific 
character(s) should be used internally, but any module 
that transmits the date should be responsible for 
converting this to the appropriate character(s) - for 
RFC2822/822 this means that all line endings *must* be 
\r\n.

smtplib currently does this, but imaplib doesn't (a bug 
has been posted about this).

To help people understand what the rules are, it would 
be nice if documentation could be added about this - 
especially for anyone developing a new module (like 
smtplib or imaplib) that transmits the data.  The 
following is from a post to the spambayes list from Paul 
Moore, which sounds good to me.  (Where it gets added 
is your problem ;)

"As a general set of rules (which aren't stated anywhere) 
it's probably fair to say that:

   1. Modules which manipulate internet-format data (like 
email) should work with line terminators of \n internally 
(just like Python strings do).
   2. Modules which transmit files across TCP/IP should 
canonicalise any form of line ending to CRLF.
   3. Modules which present data *received* from TCP/IP 
(like POP3) should convert data to \n line endings before 
returning it to the program.
   4. Reading from the filesystem should be handled like 
(3), and should support files opened in text or binary 
modes (or universal newline mode in Python 2.3)
   5. Writing to the filesystem should be done by 
assuming the data uses \n internally (the above rules 
make this true) and writing either in binary format (which 
leaves LFs in the files, ie Unix format) or in text format 
(which converts the \n characters to the platform native 
newline sequence)."
msg53863 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2003-04-20 03:57
Logged In: YES 
user_id=12800

Self-assigning
msg113197 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-07 20:21
Sorry this slipped thru the cracks so long. RDM is revamping email, most likely for 3.3, and will consider open issues in doing so.
msg113224 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-08 01:10
These guidelines need to be revamped for Python3.  The place it should go is the developer docs, which I believe will soon be moved into the main documentation tree.

It's not actually clear what the guidelines should be at this point.  We haven't really finished working through the consequences of the bytes/string separation for the standard library modules that deal with bytes-on-the-wire.
History
Date User Action Args
2022-04-10 16:08:14adminsetgithub: 38334
2014-01-05 05:29:25moijes12setnosy: - moijes12
2012-08-23 14:36:30moijes12setnosy: + moijes12
2012-05-16 01:03:50r.david.murraysetpriority: normal -> low
components: + email, - Documentation
versions: + Python 3.3, - Python 3.2
2010-08-08 01:10:37r.david.murraysetmessages: + msg113224
2010-08-07 20:21:47terry.reedysetnosy: + terry.reedy

messages: + msg113197
versions: - Python 2.6, Python 3.1, Python 2.7
2010-07-11 02:14:41terry.reedysetversions: + Python 3.1, Python 2.7, Python 3.2
2010-05-05 13:42:28barrysetassignee: barry -> r.david.murray

nosy: + r.david.murray
2009-04-22 18:49:39ajaksu2setkeywords: + easy
2009-02-12 03:21:22ajaksu2setstage: needs patch
versions: + Python 2.6
2003-04-20 02:38:38anadelonbrincreate