def get_txt(name):
    """Return a TXT record associated with a DNS name.

    @param name: The bytestring domain name to look up.
    """
    # pydns needs Unicode, but DKIM's d= is ASCII (already punycoded).
    try:
        unicode_name = name.decode('ascii')
    except UnicodeDecodeError:
        return None
    txt = _get_txt(unicode_name)
    if txt:
      txt = txt.encode('utf-8')
    return txt
Return a TXT record associated with a DNS name.

    @param name: The bytestring domain name to look up.
    
python/dkim/dnsplug.py