From a852463283f44357fec29e0bce49f3cc83ed9c2f Mon Sep 17 00:00:00 2001
From: Mark Sapiro <mark@msapiro.net>
Date: Tue, 14 Feb 2017 19:15:58 -0800
Subject: Catch NotAMemberError when member is removed before probe bounce
 returns.

---
 Mailman/Queue/BounceRunner.py | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

(limited to 'Mailman')

diff --git a/Mailman/Queue/BounceRunner.py b/Mailman/Queue/BounceRunner.py
index 651039d6..2d14f284 100644
--- a/Mailman/Queue/BounceRunner.py
+++ b/Mailman/Queue/BounceRunner.py
@@ -29,6 +29,7 @@ from email.Utils import parseaddr
 from Mailman import mm_cfg
 from Mailman import Utils
 from Mailman import LockFile
+from Mailman.Errors import NotAMemberError
 from Mailman.Message import UserNotification
 from Mailman.Bouncer import _BounceInfo
 from Mailman.Bouncers import BouncerAPI
@@ -151,19 +152,26 @@ class BounceMixin:
             mlist.Lock()
         try:
             op, addr, bmsg = mlist.pend_confirm(token)
-            info = mlist.getBounceInfo(addr)
-            if not info:
-                # info was deleted before probe bounce was received.
-                # Just create a new info.
-                info = _BounceInfo(addr,
-                                   0.0,
-                                   time.localtime()[:3],
-                                   mlist.bounce_you_are_disabled_warnings
-                                   )
-            mlist.disableBouncingMember(addr, info, bmsg)
-            # Only save the list if we're unlocking it
-            if not locked:
-                mlist.Save()
+            # For Python 2.4 compatibility we need an inner try because
+            # try: ... except: ... finally: requires Python 2.5+
+            try:
+                info = mlist.getBounceInfo(addr)
+                if not info:
+                    # info was deleted before probe bounce was received.
+                    # Just create a new info.
+                    info = _BounceInfo(addr,
+                                       0.0,
+                                       time.localtime()[:3],
+                                       mlist.bounce_you_are_disabled_warnings
+                                       )
+                mlist.disableBouncingMember(addr, info, bmsg)
+                # Only save the list if we're unlocking it
+                if not locked:
+                    mlist.Save()
+            except NotAMemberError:
+                # Member was removed before probe bounce returned.
+                # Just ignore it.
+                pass
         finally:
             if not locked:
                 mlist.Unlock()
-- 
cgit v1.2.3