import email


def email_fetch(imap, uid):
    """Returns (status, message) for an email by UID.
    Email is returned as an email.Message class object.
    """
    message = None
    status, response = imap.fetch(str(uid), '(BODY.PEEK[])')

    if status != 'OK':
        return status, response

    for i in response:
        if isinstance(i, tuple):
            s = i[1]
            if isinstance(s, bytes):
                s = s.decode('utf-8')
            message = email.message_from_string(s)

    return status, message