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: mailbox : add option to prevent platform EOL conversion
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: adder, r.david.murray
Priority: normal Keywords:

Created on 2017-05-20 12:09 by adder, last changed 2022-04-11 14:58 by admin.

Messages (2)
msg294028 - (view) Author: (adder) Date: 2017-05-20 12:09
The mailbox module will actively convert EOL format from the input mailbox, towards the EOL convention of the platform it is running on.

This is wrong.

If the mailbox originates from the same platform, as the code is executing on, it is an unnecessary conversion.
If the mailbox originates from a different platform, as the code is executing on, it is an incorrect conversion.

In general, it is best to be EOL preserving.

Please consider a solution which will be backwards compatible, by having an option when opening a mailbox to prevent EOL translations, which defaults to the current behaviour of EOL conversion.
That will prevent legacy code from breaking.
msg294108 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-05-21 18:25
I'm not entirely sure why some of the conversions are done they way they are, but I do know that one goal is to make all of the line endings consistent, whatever may be the case on disk.  If you aren't modifing the mailbox, nothing should happen.  If you are, rewriting it to be consistent would seem to me to be the correct thing to do.

If you want to propose a patch that optionally guesses the line discipline of the input file and uses it on rewrite, we'll consider it, but I'm really not sure it is worth it unless it actually simplifies the existing code and/or makes it more consistent, while still meeting the existing behavior of handling mixed line endings in the input files.
History
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74597
2017-05-21 18:25:15r.david.murraysettype: behavior -> enhancement
messages: + msg294108
versions: - Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6
2017-05-21 15:33:12xiang.zhangsetnosy: + r.david.murray
2017-05-20 12:09:06addercreate