be stricter on catched exception, fix Time parsing
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 29 May 2009 14:04:06 +0200
changeset 2002 031414d88003
parent 2001 c6bb482f40c6
child 2003 e194335569d1
be stricter on catched exception, fix Time parsing
appobject.py
--- a/appobject.py	Fri May 29 13:34:06 2009 +0200
+++ b/appobject.py	Fri May 29 14:04:06 2009 +0200
@@ -7,7 +7,7 @@
 """
 __docformat__ = "restructuredtext en"
 
-from datetime import datetime, timedelta
+from datetime import datetime, timedelta, time
 
 from logilab.common.decorators import classproperty
 from logilab.common.deprecation import obsolete
@@ -305,15 +305,15 @@
             format = self.req.property_value('ui.datetime-format')
             try:
                 return todatetime(strptime(value, format))
-            except:
+            except ValueError:
                 pass
         elif etype == 'Time':
             format = self.req.property_value('ui.time-format')
             try:
                 # (adim) I can't find a way to parse a Time with a custom format
                 date = strptime(value, format) # this returns a DateTime
-                return datetime.time(date.hour, date.minute, date.second)
-            except:
+                return time(date.hour, date.minute, date.second)
+            except ValueError:
                 raise ValueError('can\'t parse %r (expected %s)' % (value, format))
         try:
             format = self.req.property_value('ui.date-format')
@@ -321,7 +321,7 @@
             if etype == 'Datetime':
                 return todatetime(dt)
             return todate(dt)
-        except:
+        except ValueError:
             raise ValueError('can\'t parse %r (expected %s)' % (value, format))
 
     # security related methods ################################################