ihiji / version_utils

Version parsing and comparison utilities in pure python
https://pypi.python.org/pypi/version_utils
GNU General Public License v3.0
15 stars 8 forks source link

Index out of range #22

Open christianmlong opened 6 years ago

christianmlong commented 6 years ago

I'm getting an error on this test

from version_utils import rpm
def test_compare_evr_trailing_chars():
    """
    Test a fix I applied to the evr function.
    """
    evr_a = [u'0', u'2.02.98', u'9.el6_4.2']
    evr_b = [u'0', u'2.02.98', u'9.el6.']
    assert rpm.compare_evrs(evr_a, evr_b) == rpm.a_newer
        while len(chars_a) != 0 and len(chars_b) != 0:
            logger.debug('starting loop comparing %s '
                         'to %s', chars_a, chars_b)
            _check_leading(chars_a, chars_b)
            if chars_a[0] == '~' and chars_b[0] == '~':
                map(lambda x: x.pop(0), (chars_a, chars_b))
            elif chars_a[0] == '~':
                return b_newer
>           elif chars_b[0] == '~':
E           IndexError: list index out of range

../../../../.virtualenvs/ciam/lib/python2.7/site-packages/version_utils/rpm.py:173: IndexError

I think the problem is in compare_versions on line #168. _check_leading modifies a list in place, making the list empty.

I think a fix might be to add another length check at line 169, right after the call to _check_leading.

mplanchard commented 6 years ago

Hey there. Sorry I missed the notifications on this issue. I moved on from Ihiji in January, and I had all Ihiji repos set up to go to to my old work e-mail.

Thanks for the report, and especially for the PR! It looks like this repo isn't being actively maintained anymore, and I no longer have push permissions, so we may want to move work to my fork