[MERGE] versionedfile.py code cleanups
Robert Collins
robertc at robertcollins.net
Thu Sep 20 04:11:43 BST 2007
On Thu, 2007-09-20 at 13:03 +1000, Martin Pool wrote:
> On 9/20/07, Robert Collins <robertc at robertcollins.net> wrote:
> > > However, I would question whether, by LBYL, we should really be adding
> > > these rather than just letting it hit NameError. If it's the public
> > > method, where we want a docstring in the base class then it has to be
> > > there. I guess the _method may still have a docstring for subclasses.
> >
> > There is no code checked before hitting this method... all that happens
> > is a subclass that hasn't implemented the method has the base method in
> > its dict. So no LBYL is occurring, and the error is clearer than
> > NameError in some regards, though in this case I guess its clear what
> > attribute is missing - it may not be clear which class has the missing
> > method with a NameError.
>
> I'm not sure what you mean by "There is no code checked". To my mind
> this is LBYL because we're specifically preventing a situation that
> will end in a system error anyhow.
Well, I think you've made a generalisation of LBYL that is slightly
different to its normal meaning, which is about not running code to
check things that will be handled in due course. Specifically this stub
method does not introduce race conditions that LBYL do, nor waste CPU
time checking things that are checked later anyway etc.
> I did think this was clearer than NameError, but it looks like that is
> actually quite reasonable:
>
> >>> a.aoeuaoeu()
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> AttributeError: 'object' object has no attribute 'aoeuaoeu'
>
> So on the whole I don't think this is pulling its weight, *unless* you
> want the method there with a docstring but no body.
I think that the docstring use case here is quite important, and
describes what the helpers need to do.
Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070920/a620e662/attachment.pgp
More information about the bazaar
mailing list