]> granicus.if.org Git - python/commit
[Apply length-checking.diff from bug #1599254]
authorAndrew M. Kuchling <amk@amk.ca>
Wed, 20 Dec 2006 19:48:20 +0000 (19:48 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Wed, 20 Dec 2006 19:48:20 +0000 (19:48 +0000)
commiteca4c31267526dffe471bc78712dd884c4f04c34
tree7376032573207f5df59e599efa32bfccbafb7153
parentded1c4df0b98b05af22d82bd8ae8795f7c8da916
[Apply length-checking.diff from bug #1599254]

Add length checking to single-file mailbox formats: before doing a
flush() on a mailbox, seek to the end and verify its length is
unchanged, raising ExternalClashError if the file's length has
changed.

This fix avoids potential data loss if some other process appends to
the mailbox file after the table of contents has been generated;
instead of overwriting the modified file, you'll get the exception.

I also noticed that the self._lookup() call in self.flush() wasn't
necessary (everything that sets self._pending to True also calls
self.lookup()), and replaced it by an assertion.

2.5 backport candidate.
Lib/mailbox.py