[Python-checkins] cpython (3.2): #9559: Don't call _pre_mailbox_hook more than once

petri.lehtinen python-checkins at python.org
Fri Jun 29 12:55:34 CEST 2012


http://hg.python.org/cpython/rev/7cf5a629fde2
changeset:   77848:7cf5a629fde2
branch:      3.2
parent:      77844:450e32f8c73a
user:        Petri Lehtinen <petri at digip.org>
date:        Fri Jun 29 13:43:37 2012 +0300
summary:
  #9559: Don't call _pre_mailbox_hook more than once

files:
  Lib/mailbox.py |  7 +++++--
  1 files changed, 5 insertions(+), 2 deletions(-)


diff --git a/Lib/mailbox.py b/Lib/mailbox.py
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -740,8 +740,11 @@
         """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)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list