From: Petri Lehtinen Date: Fri, 29 Jun 2012 10:43:37 +0000 (+0300) Subject: #9559: Don't call _pre_mailbox_hook more than once X-Git-Tag: v3.3.0b2~367^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6ee3d6b7a3eaf7af09dbe34879a821de997e215;p=python #9559: Don't call _pre_mailbox_hook more than once --- diff --git a/Lib/mailbox.py b/Lib/mailbox.py index 8d3f8b6c2a..73c43e22f7 100644 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -740,8 +740,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)