def METHOD_NAME(source):
    try:
        handle = open(source)
    except TypeError:
        handle = source
        if handle.read(0) != "":
            raise ValueError("PHD files must be opened in text mode.") from None
    return handle