[MERGE] versionedfile.py code cleanups

Martin Pool mbp at sourcefrog.net
Thu Sep 20 04:03:28 BST 2007


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.

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.

Of course these things are needed if we have an intermediate semi
abstract class which wants to disable some methods from the base
class, perhaps expecting them to be implemented in a sub class. But
that's kind of smelly.

-- 
Martin



More information about the bazaar mailing list