[PATCH] fix for bug 12292

Douglas Bagnall douglas.bagnall at catalyst.net.nz
Wed Sep 28 10:20:20 UTC 2016


On 28/09/16 22:24, Rowland Penny wrote:

>> The attached patch is close to the mimimum necessary to fix the bug as
>> described on bugzilla. Further refactoring is not necessarily bad, but
>> it doesn't need to sneak in under bug 12292's banner.
>>
>> cheers,
>> Douglas
> 
> Might be being a bit thick here, but couldn't you not bother with the
> new class and just use:
> 
> +        except:
> +            self.outf.write("Unable to find user %s\n" % username)
> 

The trouble there is you would catch all exceptions, regardless of
their origin, which would hide real errors. For example, the search or
delete could fail, or the "assert(len(target) == 1)" could raise an
AssertionError. You need to treat generic exceptions as errors and
filter out the special cases for special treatment.

Exception subclasses are a good (simple, unambiguous, idiomatic) way
of communicating this kind of thing. We should make use of them but we
very rarely do.

Douglas



More information about the samba-technical mailing list