summaryrefslogtreecommitdiffstats
path: root/Lib/mailbox.py
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2012-06-29 10:51:19 (GMT)
committerPetri Lehtinen <petri@digip.org>2012-06-29 10:51:50 (GMT)
commit31a78c3d6521272c418f5ffbb8824d26be40db50 (patch)
tree6891dfb61053768d58673de0616f072ac058a518 /Lib/mailbox.py
parentd0f6e0a6e61d2ded83ddf46db193cf97eb3b878c (diff)
parentb6ee3d6b7a3eaf7af09dbe34879a821de997e215 (diff)
downloadcpython-31a78c3d6521272c418f5ffbb8824d26be40db50.zip
cpython-31a78c3d6521272c418f5ffbb8824d26be40db50.tar.gz
cpython-31a78c3d6521272c418f5ffbb8824d26be40db50.tar.bz2
#9559: Don't call _pre_mailbox_hook more than once
Diffstat (limited to 'Lib/mailbox.py')
-rw-r--r--Lib/mailbox.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index 39968c6..4043d74 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)