def _strToBoundNumeral(v, interval, conversion):
    """Test (and convert) a generic numerical type, with a check against a lower and upper limit.
    @param v: the literal string to be converted
    @param interval: lower and upper bounds (non inclusive). If the value is None, no comparison should be done
    @param conversion: conversion function, ie, int, long, etc
    @raise ValueError: invalid value
    """
    try:
        i = conversion(v)
        if (interval[0] is None or interval[0] < i) and (interval[1] is None or i < interval[1]):
            return i
    except:
        pass
    raise ValueError("Invalid numerical value %s" % v)