[MERGE] versionedfile.py code cleanups

Robert Collins robertc at robertcollins.net
Wed Sep 19 21:39:15 BST 2007


On Wed, 2007-09-19 at 21:12 +1000, Martin Pool wrote:
> On 9/19/07, Ian Clatworthy <ian.clatworthy at internode.on.net> wrote:
> > More minor improvements. A trivial question as well for the style gods ...
> >
> > We commonly use the pattern of having a method foo in a base class that
> > does the common stuff (e.g. parameter validation) and then calls to
> > method _foo to do the real work. In the base class, _foo simply does this:
> >
> >   raise errors.NotImplementedError(self.foo)
> >
> > Derived classes are responsible for implementing _foo. Given that,
> > should the NotImplementedError take self.foo or self._foo as it's parameter?
> 
> I would say self._foo, since that's what's not implemented.
> 
> 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.

-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/c867419a/attachment.pgp 


More information about the bazaar mailing list