]> granicus.if.org Git - python/commitdiff
#9559: Don't call _pre_mailbox_hook more than once
authorPetri Lehtinen <petri@digip.org>
Fri, 29 Jun 2012 10:43:37 +0000 (13:43 +0300)
committerPetri Lehtinen <petri@digip.org>
Fri, 29 Jun 2012 10:43:45 +0000 (13:43 +0300)
Lib/mailbox.py

index ecd9f61d76aacaa4450a6ea18ec5865912c5cd7d..fc154fa12aac998908d7ccd9311bb9761541b7b7 100644 (file)
@@ -714,8 +714,11 @@ class _singlefileMailbox(Mailbox):
         """Append message to mailbox and return (start, stop) offsets."""
         self._file.seek(0, 2)
         before = self._file.tell()
-        if len(self._toc) == 0:
-            # This is the first message
+        if len(self._toc) == 0 and not self._pending:
+            # This is the first message, and the _pre_mailbox_hook
+            # hasn't yet been called. If self._pending is True,
+            # messages have been removed, so _pre_mailbox_hook must
+            # have been called already.
             self._pre_mailbox_hook(self._file)
         try:
             self._pre_message_hook(self._file)