[Freeipa-devel] [PATCHES 0442-0449] Pylint: sunday code cleanup

Petr Spacek pspacek at redhat.com
Mon Mar 21 15:52:30 UTC 2016


On 21.3.2016 13:50, Lukas Slebodnik wrote:
> On (21/03/16 12:30), Martin Basti wrote:
>> On 21.03.2016 10:33, Christian Heimes wrote:
>>> On 2016-03-21 10:29, Petr Spacek wrote:
>>>> On 20.3.2016 21:56, Martin Basti wrote:
>>>>> Patches attached.
>>>> I do not really like
>>>> freeipa-mbasti-0442-pylint-remove-bare-except
>>>> because it replaces most of
>>>>
>>>> try: ... except:
>>>>
>>>> with
>>>>
>>>> try: ... except Exception:
>>>>
>>>>
>>>> which AFAIK does not add any value. It would be better to replace Exception
>>>> with more specific exception so the code raises an error instead of continuing
>>>> when something really unexpected happens.
>>> It adds some value. A bare except also excepts signals like
>>> KeyboardInterrupt and SystemExit. except Exception doesn't block these
>>> exceptions.
>>>
>>> But yes, more specific exceptions are better.
>>>
>>> Christian
>>>
>>>
>>>
>>>
>> 'except Exception' is another pylint check :D
>>
>> I replaced bare except with a particular exception in cases where it was
>> clear. For other occurrences of bare except it covers too much Exception
>> types, so catch Exception is more sensible, or I need crystal ball to detect
>> what kind of exceptions can be raised there.
>>
> Agree.
> 
> It can be changed to more specific exceptions type of Exception in future.
> This change is less risky.
> 
> pylint passed on fedora {23, 24, rawhide}
> 
> ACK

Okay, it makes sense.

-- 
Petr^2 Spacek




More information about the Freeipa-devel mailing list