[tor-commits] [bridgedb/master] Do not catch general Exceptions in isValidRouterNickname.
isis at torproject.org
isis at torproject.org
Sun Jan 12 06:06:34 UTC 2014
commit b385af36198afc2adc897e94858132fc36a761d6
Author: Isis Lovecruft <isis at torproject.org>
Date: Sat Dec 7 13:03:44 2013 +0000
Do not catch general Exceptions in isValidRouterNickname.
General exceptions here are never raised, and all exceptions which are
raised are handled by the calling function, parseRLine().
---
lib/bridgedb/parse/networkstatus.py | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/lib/bridgedb/parse/networkstatus.py b/lib/bridgedb/parse/networkstatus.py
index cb08bef..8a03af8 100644
--- a/lib/bridgedb/parse/networkstatus.py
+++ b/lib/bridgedb/parse/networkstatus.py
@@ -52,20 +52,14 @@ def isValidRouterNickname(nickname):
"""
ALPHANUMERIC = string.letters + string.digits
- try:
- if not (1 <= len(nickname) <= 19):
+ if not (1 <= len(nickname) <= 19):
+ raise InvalidRouterNickname(
+ "Nicknames must be between 1 and 19 characters: %r" % nickname)
+ for letter in nickname:
+ if not letter in ALPHANUMERIC:
raise InvalidRouterNickname(
- "Nicknames must be between 1 and 19 characters: %r" % nickname)
- for letter in nickname:
- if not letter in ALPHANUMERIC:
- raise InvalidRouterNickname(
- "Nicknames must only use [A-Za-z0-9]: %r" % nickname)
- except Exception as error:
- logging.exception(error)
- else:
- return True
-
- raise InvalidRouterNickname
+ "Nicknames must only use [A-Za-z0-9]: %r" % nickname)
+ return True
def parseRLine(line):
"""Parse an 'r'-line from a networkstatus document.
More information about the tor-commits
mailing list