import six


def convert_perm(perm):
    """Convert a string to an integer, interpreting the text as octal.
    Or, if `perm` is an integer, reinterpret it as an octal number that
    has been "misinterpreted" as decimal.
    """
    if isinstance(perm, six.integer_types):
        perm = six.text_type(perm)
    return int(perm, 8)