code: def idna_encode (host):
      
      if host and isinstance(host, unicode):
          try:
              host.encode('ascii')
              return host, False
          except UnicodeError:
              uhost = host.encode('idna').decode('ascii')
              return uhost, uhost != host
      return host, False
docs: Encode hostname as internationalized domain name (IDN) according
      to RFC 3490.
      @raise: UnicodeError if hostname is not properly IDN encoded.