From 16bfe5d4da7b0206b6b628ff50b82dc69374c045 Mon Sep 17 00:00:00 2001
From: Stuart Gathman <stuart@gathman.org>
Date: Fri, 13 Apr 2012 20:33:35 +0000
Subject: [PATCH] Exceptions on unsupported result code for callback
 decorators.

---
 Milter/__init__.py | 15 ++++++++++++---
 pymilter.spec      |  4 ++++
 setup.py           |  2 +-
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Milter/__init__.py b/Milter/__init__.py
index 9e59f09..8fed7ad 100755
--- a/Milter/__init__.py
+++ b/Milter/__init__.py
@@ -8,7 +8,7 @@
 # Copyright 2001,2009 Business Management Systems, Inc.
 # This code is under the GNU General Public License.  See COPYING for details.
 
-__version__ = '0.9.5'
+__version__ = '0.9.7'
 
 import os
 import milter
@@ -137,7 +137,12 @@ def nocallback(func):
   except KeyError:
     raise ValueError(
       '@nocallback applied to non-optional method: '+func.__name__)
-  return func
+  def wrapper(self,*args):
+    if func(self,*args) != CONTINUE:
+      raise RuntimeError('%s return code must be CONTINUE with @nocallback'
+        % func.__name__)
+    return CONTINUE
+  return wrapper
 
 ## Function decorator to disable callback reply.
 # If the MTA supports it, tells the MTA not to wait for a reply from
@@ -154,7 +159,11 @@ def noreply(func):
       '@noreply applied to non-optional method: '+func.__name__)
   def wrapper(self,*args):
     rc = func(self,*args)
-    if self._protocol & nr_mask: return NOREPLY
+    if self._protocol & nr_mask:
+      if rc != CONTINUE:
+        raise RuntimeError('%s return code must be CONTINUE with @noreply'
+	  % func.__name__)
+      return NOREPLY
     return rc
   wrapper.milter_protocol = nr_mask
   return wrapper
diff --git a/pymilter.spec b/pymilter.spec
index 4e91211..5c10478 100644
--- a/pymilter.spec
+++ b/pymilter.spec
@@ -75,6 +75,10 @@ chmod a+x $RPM_BUILD_ROOT%{libdir}/start.sh
 rm -rf $RPM_BUILD_ROOT
 
 %changelog
+* Sat Feb 25 2012 Stuart Gathman <stuart@bmsi.com> 0.9.7-1
+- Raise RuntimeError when result != CONTINUE for @noreply and @nocallback
+- Remove redundant table in miltermodule
+
 * Sat Feb 25 2012 Stuart Gathman <stuart@bmsi.com> 0.9.6-1
 - Raise ValueError on unescaped '%' passed to setreply
 - Grace time at end of Greylist window
diff --git a/setup.py b/setup.py
index 3800c90..046bae9 100644
--- a/setup.py
+++ b/setup.py
@@ -13,7 +13,7 @@ libs = ["milter"]
 libdirs = ["/usr/lib/libmilter"]    # needed for Debian
 
 # NOTE: importing Milter to obtain version fails when milter.so not built
-setup(name = "pymilter", version = '0.9.6',
+setup(name = "pymilter", version = '0.9.7',
 	description="Python interface to sendmail milter API",
 	long_description="""\
 This is a python extension module to enable python scripts to
-- 
GitLab