Skip to content

Index out of range #22

@christianmlong

Description

@christianmlong

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions