python / cpython

The Python programming language
https://www.python.org
Other
62.33k stars 29.94k forks source link

mailbox Babyl support should use visible header as full header when full header is empty #114579

Open jikamens opened 7 months ago

jikamens commented 7 months ago

Bug report

Bug description:

The Babyl message file format supported by the mailbox module has two sections for headers; a "full" header section and a "visible" headers section. Software that uses the Babyl software natively interprets an empty "full" header section as meaning that the visible and full headers are identical, so they don't have to be stored twice in the file. The Python module doesn't do this; if it encounters a message in a Babyl file which has nothing between the labels line and the '*** EOOH *** line, it creates a message object with no headers. Instead, in this case it should interpret the headers after the *** EOOH *** line as full headers for the message.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

serhiy-storchaka commented 7 months ago

Thank you for your report. What software interprets an empty "full" header section as meaning that the visible and full headers are identical? Are you interesting in creating a PR?

jikamens commented 7 months ago

Thank you for your report. What software interprets an empty "full" header section as meaning that the visible and full headers are identical?

I mean, is there any software besides Emacs that uses Babyl format anymore? ;-)

I'm pretty sure Emacs behaves as I described.

Are you interesting in creating a PR?

As I noted in the other ticket, I'll try, but I am very busy and can't make any promises about when I'll get to it.

serhiy-storchaka commented 7 months ago

Since Python module is lower level than the Emacs application, I wonder whether it is okay to keep "full" headers empty and let the application to decide if it want to use "visible" headers in this case.

jikamens commented 7 months ago

The question I'm concerned about is what happens when you read a message from a BABYL file and immediately insert it into an MBOX file. I believe that should work properly out of the box, and it doesn't right now if the BABYL message has no full header; the message in the MBOX file just ends up with an empty header, which is obviously wrong. If there were an init kwarg or some other way to indicate when creating the BABYL mailbox object that all messages created by that object should use the visible header as the full header when the latter is empty, then I suppose that would be sufficient, but I personally think it would be preferable for that to be the default behavior. :shrug: