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

MRAB google at
Sat Apr 25 19:33:31 CEST 2009

tinnews at wrote:
> Grant Edwards <invalid at invalid> wrote:
>> On 2009-04-24, Grant Edwards <invalid at invalid> wrote:
>>> 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.
>> I should qualify that: since the documentation for add()
>> doesn't specify whether or not it's supposed to add a "new"
>> message or an "old" message, one could argue that either
>> behavior is correct.
>> However, since the maildir add() method adds a "new" message,
>> one would reasonably expect that the mbox add() method do the
>> same.  Or, I suppose one might expect the converse: since mbox
>> add() creates an "old" message, then maildir add() should do
>> the same.
>> I have my filesystems mouted with the "noatime" option and use
>> maildir...
> Whatever, if mailbox.mbox.add() doesn't preserve the atime when adding
> messages to an mbox then it's close to useless.
> I suppose I could do the following:-
>     lock the mbox
>     get the atime
>     add the new message with mailbox.mbox.add()
>     restore the atime
>     unlock the mbox
> All I need to do now is find out how to get and set atime with python.
os.utime(path, (atime, mtime))

More information about the Python-list mailing list