[Python-checkins] cpython (2.7): #9559: Don't call _pre_mailbox_hook more than once
petri.lehtinen
python-checkins at python.org
Fri Jun 29 12:55:33 CEST 2012
http://hg.python.org/cpython/rev/3d7a75e945ee
changeset: 77847:3d7a75e945ee
branch: 2.7
parent: 77843:bbfee24e5ad2
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
@@ -714,8 +714,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