code: def to_bytes(url):
      
      # Most URL schemes require ASCII. If that changes, the conversion
      # can be relaxed.
      # XXX get rid of to_bytes()
      if isinstance(url, str):
          try:
              url = url.encode("ASCII").decode()
          except UnicodeError:
              raise UnicodeError("URL " + repr(url) +
                                 " contains non-ASCII characters")
      return url
docs: to_bytes(u"URL") --> 'URL'.