[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] 4297 - Exception Oddities
commit c04f4035fbadc48872ac9f0cc30fe69019af3e8e
Author: aagbsn <aagbsn@xxxxxxxx>
Date: Tue Feb 28 14:22:05 2012 -0800
4297 - Exception Oddities
Some versions (tested with 2.6.6) of Python exhibit odd exception
handling behavior; this fix corrects an issue where the parent
class exception handler was catching exceptions meant for a
subclassed exception handler
---
lib/bridgedb/Server.py | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/lib/bridgedb/Server.py b/lib/bridgedb/Server.py
index 6db4522..a2460b8 100644
--- a/lib/bridgedb/Server.py
+++ b/lib/bridgedb/Server.py
@@ -32,6 +32,7 @@ from bridgedb.Raptcha import Raptcha
import base64
import textwrap
from ipaddr import IPv4Address, IPv6Address
+from bridgedb.Dist import BadEmail, TooSoonEmail, IgnoreEmail
try:
import GeoIP
@@ -364,7 +365,7 @@ def getMailResponse(lines, ctx):
try:
_, addrdomain = bridgedb.Dist.extractAddrSpec(clientAddr.lower())
- except bridgedb.Dist.BadEmail:
+ except BadEmail:
logging.info("Ignoring bad address on incoming email.")
return None,None
if not addrdomain:
@@ -412,13 +413,8 @@ def getMailResponse(lines, ctx):
interval, ctx.N,
countryCode=None,
bridgeFilterRules=rules)
- except bridgedb.Dist.BadEmail, e:
- logging.info("Got a mail from a bad email address %r: %s.",
- clientAddr, e)
- return None, None
-
# Handle rate limited email
- except bridgedb.Dist.TooSoonEmail, e:
+ except TooSoonEmail, e:
logging.info("Got a mail too frequently; warning %r: %s.",
clientAddr, e)
@@ -441,11 +437,16 @@ def getMailResponse(lines, ctx):
f.seek(0)
return clientAddr, f
- except bridgedb.Dist.IgnoreEmail, e:
+ except IgnoreEmail, e:
logging.info("Got a mail too frequently; ignoring %r: %s.",
clientAddr, e)
return None, None
+ except BadEmail, e:
+ logging.info("Got a mail from a bad email address %r: %s.",
+ clientAddr, e)
+ return None, None
+
# Generate the message.
f = StringIO()
w = MimeWriter.MimeWriter(f)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits