[Kimchi-devel] [PATCH] bug fix: Properly display missing parameter
Aline Manera
alinefm at linux.vnet.ibm.com
Tue Feb 25 15:02:29 UTC 2014
On 02/25/2014 11:56 AM, Sheldon wrote:
> On 02/25/2014 10:47 PM, Aline Manera wrote:
>>>>
>>>> The exception instance was being used as the missing parameter what is
>>>> causing errors like below:
>>> is KeyError?
>>>
>>> dic = {"a": "a"}
>>> In [124]: dic['b']
>>> ---------------------------------------------------------------------------
>>>
>>> KeyError: 'b'
>>>
>>>
>>> or TypeError?
>>>>
>>>> TypeError: coercing to Unicode: need string or buffer,
>>>> exceptions.KeyError found
>>
>> As you can see the TypeError is caused by an KeyError
> as I comment as follow:
> except KeyError, item:
> key is better than item?
why? it is a reference to the exception
But I am OK with both
Anyway, this is not the scope of this patch
>>
>>>>
>>>> To fix use the string representation for the exception instance.
>>>>
>>>> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
>>>> ---
>>>> src/kimchi/mockmodel.py | 4 ++--
>>>> src/kimchi/model/storagepools.py | 2 +-
>>>> src/kimchi/model/storagevolumes.py | 2 +-
>>>> src/kimchi/root.py | 2 +-
>>>> 4 files changed, 5 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
>>>> index b50bf31..b23a024 100644
>>>> --- a/src/kimchi/mockmodel.py
>>>> +++ b/src/kimchi/mockmodel.py
>>>> @@ -367,7 +367,7 @@ class MockModel(object):
>>>> pool.info['autostart'] = False
>>>> except KeyError, item:
>>>> raise MissingParameter("KCHPOOL0004E",
>>>> - {'item': item, 'name': name})
>>>> + {'item': str(item), 'name': name})
>>> except KeyError, key:
>>> key is right than item
> here.
>>>
>>>>
>>>> if name in self._mock_storagepools or name in
>>>> (ISO_POOL_NAME,):
>>>> raise InvalidOperation("KCHPOOL0001E", {'name': name})
>
>
More information about the Kimchi-devel
mailing list