summaryrefslogtreecommitdiffstats
path: root/Lib/mailbox.py
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2012-06-29 10:43:37 (GMT)
committerPetri Lehtinen <petri@digip.org>2012-06-29 10:43:45 (GMT)
commit4e6e5a06bbdba83389510331f5b0f2047e21ccd5 (patch)
treeac628f069acb436a159c75ba5016665f27714589 /Lib/mailbox.py
parent9d5d507322e828c8285f68d90bd49c9ca8833a89 (diff)
downloadcpython-4e6e5a06bbdba83389510331f5b0f2047e21ccd5.zip
cpython-4e6e5a06bbdba83389510331f5b0f2047e21ccd5.tar.gz
cpython-4e6e5a06bbdba83389510331f5b0f2047e21ccd5.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 ecd9f61..fc154fa 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -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)