Bad code in bzrlib.inventory

Jan Hudec bulb at
Mon May 1 08:38:42 BST 2006


I have noticed a bad code in bzrlib/, that only works by luck:

1. class Inventory defines __slots__ that do NOT include symlink_target.
2. It's __init__ ASSIGNS self.symlink_target
3. It's __eq__ COMPARES self.symlink_target
That's bad, right?
4. class RootEntry does not define __slots__, which gives it a __dict__
5. class InventoryDir does not define __slots__, so again has __dict__
6. class InventoryFile does not define __slots__, so again has __dict__
7. class InventoryLink defines __slots__ = ['symlink_target']
So all the actually instantiated classes either have dict (wasn't the point
of using __slots__ to avoid allocating one?) or have that slot and therefore
the references in the base class work. In other places (like the serializer)
references to the attribute are made. But should it really work this way??

						 Jan 'Bulb' Hudec <bulb at>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : 

More information about the bazaar mailing list