[Bug 516783] Re: Version does not implement __hash__

Bug Watch Updater 516783 at bugs.launchpad.net
Thu Aug 11 04:43:15 UTC 2011


** Changed in: python-debian (Debian)
       Status: Unknown => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python-debian in Ubuntu.
https://bugs.launchpad.net/bugs/516783

Title:
  Version does not implement __hash__

Status in “python-debian” package in Ubuntu:
  Fix Released
Status in “python-debian” package in Debian:
  Fix Released

Bug description:
  Binary package hint: python-debian

  The debian_bundle.changelog.Version class implements __eq__ but not
  __hash__

  As such, you can almost-but-not-quite use them as dict entries.
  Consider

  v1 = Version('1.1.1-2')
  v2 = Version('1.1.1-2')

  assert v1 == v2

  d = {v1: 'content'}
  assert d[v1] == 'content' # True
  assert d[v2] == 'content' # False

  The reason is that Version uses the default id(obj) as the hash key.

  I think a reasonable implementation would be:

    def __hash__(self):
      return hash(self.full_version)

  Assuming that if self.full_version == other.full_version than self ==
  other.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-debian/+bug/516783/+subscriptions




More information about the foundations-bugs mailing list