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>
Wed, 24 Mar 2010 07:53:25 +0000 (09:53 +0200)
commit40f788a7bf3741f9c613ff302d4e1b0ceec2658c
treec65a9b13e7b019aad4417ca56c6567078cced81d
parent8c7e53ec80e84f48bfc67181f3d5dd81ecdb7523
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
python/rpmmi-py.c