Issue 30412: mailbox : add option to prevent platform EOL conversion (original) (raw)

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.

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.