mailbox.mbox.add() sets access time as well as modification time

Grant Edwards invalid at invalid
Fri Apr 24 16:38:10 CEST 2009

On 2009-04-23, MRAB <google at> wrote:
> tinnews at wrote:
>> It seems to me that mailbox.mbox.add() sets the access time of a mbox
>> file as well as the modification time.  This is not good for MUAs that
>> detect new mail by looking to see if the access time is before the
>> modification time.
>> Have I done something wrong somewhere or is mailbox.mbox.add() really
>> as broken as it would appear?
> [snip]
> The access time is the time it was last accessed, ie read or modified.


> The modification time is the time it was last modified.


> The access time can never be before the modification time because it
> must be accessed in order to be modified!

Nonsense.  You can set atime and mtime to anything you want.

SOP for writing to to an mbox formatted mailbox is to preserve
the atime (changing only the mtime) so that other programs know
that that there is "new" mail in the mbox.  I know mutt works
that way, and I believe that the "you've got new mail" features
in some shells work that way.  AFAIK, atime<mtime has been the
"standard" way to determine when an mbox contains new mail for
at least 20 years.

Anybody writing to an mbox mailbox has to follow the rules if
they expect to interoperate with other mail applications.  If
mailbox.mbox.add() doesn't preserve the atime when writing to
an mbox, then mailbox.mbox.add is broken.

Grant Edwards                   grante             Yow! I put aside my copy
                                  at               of "BOWLING WORLD" and
                                 think about GUN CONTROL

More information about the Python-list mailing list