Skip to content

Commit 3ff321a

Browse files
author
Richard Jones
committed
Cleaned up some bare except statements
1 parent 89e2c66 commit 3ff321a

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

roundup/hyperdb.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: hyperdb.py,v 1.40 2001-12-14 23:42:57 richard Exp $
18+
# $Id: hyperdb.py,v 1.41 2001-12-15 23:47:47 richard Exp $
1919

2020
__doc__ = """
2121
Hyperdatabase implementation, especially field types.
@@ -159,7 +159,7 @@ def create(self, **propvalues):
159159
if not num_re.match(value):
160160
try:
161161
value = self.db.classes[link_class].lookup(value)
162-
except:
162+
except (TypeError, KeyError):
163163
raise IndexError, 'new property "%s": %s not a %s'%(
164164
key, value, link_class)
165165
elif not self.db.hasnode(link_class, value):
@@ -184,7 +184,7 @@ def create(self, **propvalues):
184184
if not num_re.match(entry):
185185
try:
186186
entry = self.db.classes[link_class].lookup(entry)
187-
except:
187+
except (TypeError, KeyError):
188188
raise IndexError, 'new property "%s": %s not a %s'%(
189189
key, entry, self.properties[key].classname)
190190
l.append(entry)
@@ -330,7 +330,7 @@ class or a KeyError is raised.
330330
if not num_re.match(value):
331331
try:
332332
value = self.db.classes[link_class].lookup(value)
333-
except:
333+
except (TypeError, KeyError):
334334
raise IndexError, 'new property "%s": %s not a %s'%(
335335
key, value, self.properties[key].classname)
336336

@@ -359,7 +359,7 @@ class or a KeyError is raised.
359359
if not num_re.match(entry):
360360
try:
361361
entry = self.db.classes[link_class].lookup(entry)
362-
except:
362+
except (TypeError, KeyError):
363363
raise IndexError, 'new property "%s": %s not a %s'%(
364364
key, entry, self.properties[key].classname)
365365
l.append(entry)
@@ -599,7 +599,7 @@ def filter(self, filterspec, sort, group, num_re = re.compile('^\d+$')):
599599
elif not num_re.match(entry):
600600
try:
601601
entry = link_class.lookup(entry)
602-
except:
602+
except (TypeError,KeyError):
603603
raise ValueError, 'property "%s": %s not a %s'%(
604604
k, entry, self.properties[k].classname)
605605
u.append(entry)
@@ -615,7 +615,7 @@ def filter(self, filterspec, sort, group, num_re = re.compile('^\d+$')):
615615
if not num_re.match(entry):
616616
try:
617617
entry = link_class.lookup(entry)
618-
except:
618+
except (TypeError,KeyError):
619619
raise ValueError, 'new property "%s": %s not a %s'%(
620620
k, entry, self.properties[k].classname)
621621
u.append(entry)
@@ -723,11 +723,8 @@ def sortfun(a, b, sort=sort, group=group, properties=self.getprops(),
723723
if (isinstance(propclass, String) or
724724
isinstance(propclass, Date)):
725725
# it might be a string that's really an integer
726-
try:
727-
av = int(av)
728-
bv = int(bv)
729-
except:
730-
pass
726+
av = int(av)
727+
bv = int(bv)
731728
if dir == '+':
732729
r = cmp(av, bv)
733730
if r != 0: return r
@@ -871,6 +868,11 @@ def Choice(name, *options):
871868

872869
#
873870
# $Log: not supported by cvs2svn $
871+
# Revision 1.40 2001/12/14 23:42:57 richard
872+
# yuck, a gdbm instance tests false :(
873+
# I've left the debugging code in - it should be removed one day if we're ever
874+
# _really_ anal about performace :)
875+
#
874876
# Revision 1.39 2001/12/02 05:06:16 richard
875877
# . We now use weakrefs in the Classes to keep the database reference, so
876878
# the close() method on the database is no longer needed.

0 commit comments

Comments
 (0)