original_docstring: Encode a dict or sequence of two-element tuples into a URL query string.
  
      If any values in the query arg are sequences and doseq is true, each
      sequence element is converted to a separate parameter.
  
      If the query arg is a sequence of two-element tuples, the order of the
      parameters in the output will match the order of parameters in the
      input.
  
      The components of a query arg may each be either a string or a bytes type.
  
      The safe, encoding, and errors parameters are passed down to the function
      specified by quote_via (encoding and errors only if a component is a str).
      
docstring: Encode a dict or sequence of two-element tuples into a URL query string.
  If any values in the query arg are sequences and doseq is true, each
  sequence element is converted to a separate parameter.
  
  If the query arg is a sequence of two-element tuples, the order of the
  parameters in the output will match the order of parameters in the
  input.
  
  The components of a query arg may each be either a string or a bytes type.
  
  The safe, encoding, and errors parameters are passed down to the function
  specified by quote_via (encoding and errors only if a component is a str).
docstring_tokens: Encode a dict or sequence of two - element tuples into a URL query string . If any values in the query arg are sequences and doseq is true each sequence element is converted to a separate parameter . If the query arg is a sequence of two - element tuples the order of the parameters in the output will match the order of parameters in the input . The components of a query arg may each be either a string or a bytes type . The safe encoding and errors parameters are passed down to the function specified by quote_via ( encoding and errors only if a component is a str ) .
code: def urlencode3(query, doseq=False, safe="", encoding=None, errors=None,
                quote_via=quote_plus, querydelimiter="&"):
      """Encode a dict or sequence of two-element tuples into a URL query string.
  
      If any values in the query arg are sequences and doseq is true, each
      sequence element is converted to a separate parameter.
  
      If the query arg is a sequence of two-element tuples, the order of the
      parameters in the output will match the order of parameters in the
      input.
  
      The components of a query arg may each be either a string or a bytes type.
  
      The safe, encoding, and errors parameters are passed down to the function
      specified by quote_via (encoding and errors only if a component is a str).
      """
  
      if hasattr(query, "items"):
          query = query.items()
      else:
          # It's a bother at times that strings and string-like objects are
          # sequences.
          try:
              # non-sequence items should not work with len()
              # non-empty strings will fail this
              if len(query) and not isinstance(query[0], tuple):
                  raise TypeError
              # Zero-length sequences of all types will get here and succeed,
              # but that's a minor nit.  Since the original implementation
              # allowed empty dicts that type of behavior probably should be
              # preserved for consistency
          except TypeError:
              ty, va, tb = sys.exc_info()
              raise TypeError("not a valid non-string sequence "
                              "or mapping object").with_traceback(tb)
  
      l = []
      if not doseq:
          for k, v in query:
              if isinstance(k, bytes):
                  k = quote_via(k, safe)
              else:
                  k = quote_via(str(k), safe, encoding, errors)
  
              if isinstance(v, bytes):
                  v = quote_via(v, safe)
              else:
                  v = quote_via(str(v), safe, encoding, errors)
              l.append(k + '=' + v)
      else:
          for k, v in query:
              if isinstance(k, bytes):
                  k = quote_via(k, safe)
              else:
                  k = quote_via(str(k), safe, encoding, errors)
  
              if isinstance(v, bytes):
                  v = quote_via(v, safe)
                  l.append(k + '=' + v)
              elif isinstance(v, str):
                  v = quote_via(v, safe, encoding, errors)
                  l.append(k + '=' + v)
              else:
                  try:
                      # Is this a sufficient test for sequence-ness?
                      x = len(v)
                  except TypeError:
                      # not a sequence
                      v = quote_via(str(v), safe, encoding, errors)
                      l.append(k + '=' + v)
                  else:
                      # loop over the sequence
                      for elt in v:
                          if isinstance(elt, bytes):
                              elt = quote_via(elt, safe)
                          else:
                              elt = quote_via(str(elt), safe, encoding, errors)
                          l.append(k + '=' + elt)
      return querydelimiter.join(l)
code_tokens: def urlencode3 ( query , doseq = False , safe = "" , encoding = None , errors = None , quote_via = quote_plus , querydelimiter = "&" ) : if hasattr ( query , "items" ) : query = query . items ( ) else : try : if len ( query ) and not isinstance ( query [ 0 ] , tuple ) : raise TypeError except TypeError : ty , va , tb = sys . exc_info ( ) raise TypeError ( "not a valid non-string sequence " "or mapping object" ) . with_traceback ( tb ) l = [ ] if not doseq : for k , v in query : if isinstance ( k , bytes ) : k = quote_via ( k , safe ) else : k = quote_via ( str ( k ) , safe , encoding , errors ) if isinstance ( v , bytes ) : v = quote_via ( v , safe ) else : v = quote_via ( str ( v ) , safe , encoding , errors ) l . append ( k + '=' + v ) else : for k , v in query : if isinstance ( k , bytes ) : k = quote_via ( k , safe ) else : k = quote_via ( str ( k ) , safe , encoding , errors ) if isinstance ( v , bytes ) : v = quote_via ( v , safe ) l . append ( k + '=' + v ) elif isinstance ( v , str ) : v = quote_via ( v , safe , encoding , errors ) l . append ( k + '=' + v ) else : try : x = len ( v ) except TypeError : v = quote_via ( str ( v ) , safe , encoding , errors ) l . append ( k + '=' + v ) else : for elt in v : if isinstance ( elt , bytes ) : elt = quote_via ( elt , safe ) else : elt = quote_via ( str ( elt ) , safe , encoding , errors ) l . append ( k + '=' + elt ) return querydelimiter . join ( l )
short_docstring: Encode a dict or sequence of two-element tuples into a URL query string.
short_docstring_tokens: Encode a dict or sequence of two - element tuples into a URL query string .
comment: """Encode a dict or sequence of two-element tuples into a URL query string.
  
      If any values in the query arg are sequences and doseq is true, each
      sequence element is converted to a separate parameter.
  
      If the query arg is a sequence of two-element tuples, the order of the
      parameters in the output will match the order of parameters in the
      input.
  
      The components of a query arg may each be either a string or a bytes type.
  
      The safe, encoding, and errors parameters are passed down to the function
      specified by quote_via (encoding and errors only if a component is a str).
      """$SEP$# It's a bother at times that strings and string-like objects are$SEP$# sequences.$SEP$# non-sequence items should not work with len()$SEP$# non-empty strings will fail this$SEP$# Zero-length sequences of all types will get here and succeed,$SEP$# but that's a minor nit.  Since the original implementation$SEP$# allowed empty dicts that type of behavior probably should be$SEP$# preserved for consistency$SEP$# Is this a sufficient test for sequence-ness?$SEP$# not a sequence$SEP$# loop over the sequence