[Kimchi-devel] [PATCH] bug fix: Properly display missing parameter

Sheldon shaohef at linux.vnet.ibm.com
Tue Feb 25 14:56:10 UTC 2014


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?
>
>>>
>>> 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}) 


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list