code: def decode(var, encoding):
      
      if PY2:
          if isinstance(var, unicode):
              ret = var
          elif isinstance(var, str):
              if encoding:
                  ret = var.decode(encoding)
              else:
                  ret = unicode(var)
          else:
              ret = unicode(var)
      else:
          ret = str(var)
      return ret
docs: If not already unicode, decode it.