code: def iri_to_uri(iri, kwargs=None):
      '''Convert an Internationalised Resource Identifier (IRI) portion
      to a URI portion that is suitable for inclusion in a URL.
      This is the algorithm from section 3.1 of RFC 3987.
      Returns an ASCII native string containing the encoded result.
      '''
      if iri is None:
          return iri
      if kwargs:
          iri = '%s?%s' % (to_string(iri, 'latin1'),
                           '&'.join(('%s=%s' % kv for kv in kwargs.items())))
      return urlquote(unquote_unreserved(iri)f iri_to_uri(iri, kwargs=None):
      '''Convert an Internationalised Resource Identifier (IRI) portion
      to a URI portion that is suitable for inclusion in a URL.
      This is the algorithm from section 3.1 of RFC 3987.
      Returns an ASCII native string containing the encoded result.
      '''
      if iri is None:
          return iri
      if kwargs:
          iri = '%s?%s' % (to_string(iri, 'latin1'),
                           '&'.join(('%s=%s' % kv for kv in kwargs.items())))
      return urlquote(unquote_unreserved(iri))
docs: Convert an Internationalised Resource Identifier (IRI) portion
      to a URI portion that is suitable for inclusion in a URL.
      This is the algorithm from section 3.1 of RFC 3987.
      Returns an ASCII native string containing the encoded result.