Add __bool__() / __nonzero__() method to python rpmmi objects (ticket #153)
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 24 Mar 2010 07:53:25 +0000 (09:53 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 11 Jun 2010 07:17:19 +0000 (10:17 +0300)
commit9a93c9364d15cb569c6c9492be9ed992d28a3fc3
tree3c45cbc63aa9455bbbca7c37d7eca12eea6c10e8
parent783dd6413aaf9a2fe3a951028c33884fdd16aec1
Add __bool__() / __nonzero__() method to python rpmmi objects (ticket #153)
- Objects supporting __len__() use (len > 0) for boolean representation,
  which normally makes sense but as the match iterator count is often
  zero despite the iterator actually existing and returning something,
  and breaks existing code (rpmlint at least)
- Adding a __bool__() (known as __nonzero__() in Python < 3) method
  returning true for non-NULL iterator fixes this and gives more
  meaningful answers than pre 4.8.0 which simply always returned True
(cherry picked from commit 40f788a7bf3741f9c613ff302d4e1b0ceec2658c)
python/rpmmi-py.c