ia64/xen-unstable

changeset 7836:151837f6c26b

Remove the handling of TypeError inside gather. It is not thrown by int()
when given a non-convertible value, as claimed by the comment, as the exception
ValueError is thrown in that situation. TypeError is only thrown on int(None),
which cannot actually take place in this code, because of the explicit check
for None.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Tue Nov 15 18:47:39 2005 +0100 (2005-11-15)
parents 49bf2a4863b6
children 210a5b625e30
files tools/python/xen/xend/xenstore/xstransact.py
line diff
     1.1 --- a/tools/python/xen/xend/xenstore/xstransact.py	Tue Nov 15 17:22:42 2005 +0100
     1.2 +++ b/tools/python/xen/xend/xenstore/xstransact.py	Tue Nov 15 18:47:39 2005 +0100
     1.3 @@ -177,18 +177,15 @@ class xstransact:
     1.4                  (key, fn, defval) = tup
     1.5  
     1.6              val = self._read(key)
     1.7 -            # If fn is str, then this will successfully convert None to
     1.8 -            # 'None'.  If it is int, then it will throw TypeError on None, or
     1.9 -            # on any other non-integer value.  We have to, therefore, both
    1.10 -            # check explicitly for None, and catch TypeError.  Either failure
    1.11 -            # will result in defval being used instead.
    1.12 +            # If fn is str, then this will successfully convert None to 'None'
    1.13 +            # (which we don't want).  If it is int or float, then it will
    1.14 +            # throw ValueError on any non-convertible value.  We check
    1.15 +            # explicitly for None, using defval instead, but allow ValueError
    1.16 +            # to propagate.
    1.17              if val is None:
    1.18                  val = defval
    1.19              else:
    1.20 -                try:
    1.21 -                    val = fn(val)
    1.22 -                except TypeError:
    1.23 -                    val = defval
    1.24 +                val = fn(val)
    1.25              ret.append(val)
    1.26          if len(ret) == 1:
    1.27              return ret[0]