[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Remove the handling of TypeError inside gather. It is not thrown by int()
# HG changeset patch # User emellor@xxxxxxxxxxxxxxxxxxxxxx # Node ID 151837f6c26b2cf70d8083915235f4907c9e84a1 # Parent 49bf2a4863b6b9cc4c1e03d51c6654da0a39406e 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@xxxxxxxxxxxxx> diff -r 49bf2a4863b6 -r 151837f6c26b tools/python/xen/xend/xenstore/xstransact.py --- a/tools/python/xen/xend/xenstore/xstransact.py Tue Nov 15 16:22:42 2005 +++ b/tools/python/xen/xend/xenstore/xstransact.py Tue Nov 15 17:47:39 2005 @@ -177,18 +177,15 @@ (key, fn, defval) = tup val = self._read(key) - # If fn is str, then this will successfully convert None to - # 'None'. If it is int, then it will throw TypeError on None, or - # on any other non-integer value. We have to, therefore, both - # check explicitly for None, and catch TypeError. Either failure - # will result in defval being used instead. + # If fn is str, then this will successfully convert None to 'None' + # (which we don't want). If it is int or float, then it will + # throw ValueError on any non-convertible value. We check + # explicitly for None, using defval instead, but allow ValueError + # to propagate. if val is None: val = defval else: - try: - val = fn(val) - except TypeError: - val = defval + val = fn(val) ret.append(val) if len(ret) == 1: return ret[0] _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |