def strip_tag(version):
    """
    Strip trailing non-numeric components from a version leaving the Teradata
    't' on the final version component if it's present.
    ['1', '2', 'THREE'] -> (1, 2)
    ['1', 'TWO', '3'] -> raises a ValueError
    ['0', '115t', 'SNAPSHOT'] -> (0, '115t')
    ['ZERO', '123t'] -> raises a ValueError

    This checks the components of the version from least to most significant.
    Tags are only allowed at the least significant place in a version number,
    i.e. as the right-most component.

    Anything that can't be parsed as an integer that isn't in the right-most
    position is considered an error.

    :param version: something that can be sliced
    :return: a tuple containing only integer components, except for possibly
             the last one, which will be a string iff it's an integer followed
             by the letter 't'
    """
    is_teradata = False
    is_ancient = False

    result = list(version[:])
    while True:
        try:
            rightmost = result[-1]
            int(rightmost)
            # Once we find the right-most/least significant component that
            # can be represented as an int (doesn't raise a ValueError), break
            # out of the loop.
            break
        except ValueError:
            # Ancient tagged versions had the tag delimited by a - rather than
            # a ., spilt on -, and take the left-most token. The pattern
            # ensures that the component consists of numbers followed by a tag.
            # Once we've matched the pattern, we know the left-most token can
            # be converted by the int() function, and we're done removing
            # components.
            if ANCIENT_TAGGED_VERSION.match(rightmost):
                is_ancient = True
                result[-1] = rightmost.split('-')[0]

            # Do this second, and get the right-most component by index to get
            # the updated value for an ancient tagged version. If the pattern
            # matches, we know that except for the trailing t, the remainder of
            # the last component is a number int can parse.
            if TD_VERSION.match(result[-1]):
                is_teradata = True
                break

            # Non-teradata ancient tag. See above. We know this component is
            # numeric and we should break out of the loop and check the
            # components to the left of it.
            if is_ancient:
                break
            result = result[:-1]
        except __HOLE__:
            # If every component of the version has been removed because it's
            # non-numeric, we'll try to slice [][-1], and get an IndexError.
            # In that case, we've started with something that wasn't a version.
            raise ValueError(
                '%s does not contain any numeric version information' %
                (version,))

    # Verify that every component left of the right-most int() parseable
    # component is parseable by int(). For Teradata versions, preserve the
    # Teradata 't' on the final component.
    if is_teradata:
        result = [int(x) for x in result[:-1]] + [result[-1]]
    else:
        result = [int(x) for x in result]

    return tuple(result)
dataset/ETHPy150Open prestodb/presto-admin/prestoadmin/util/version_util.py/strip_tag