code: def convert(obj, encoding=LOCALE, level=None):
      
  
      callable_ = CONVERTERS.get(type(obj))
      if callable_ is not None:
          obj = callable_(obj)
  
      func = lambda x, level: compat.template.format(x)
  
      if isinstance(obj, compat.UnicodeType):
          # skip if condition, because unicode is a iterable type
          pass
      elif isinstance(obj, str):
          func = lambda x, level: u"'{}'".format(x.decode(encoding))
      elif isinstance(obj, (bytearray, bytes)):
          func = lambda x, level: u"b'{}'".format(
              u''.join(u'\\x{:02x}'.format(b) for b in x)
          )
      elif isinstance(obj, (type(None), int, float)):
          func = lambda x, level: compat.UnicodeType(x)
      elif isinstance(obj, (types.GeneratorType, compat.XRangeType)):
          func = lambda x, level: u"'{!r}'".format(x)
      elif isinstance(obj, collections.Mapping):
          func = unimapping
      elif isinstance(obj, collections.Iterable):
          func = uniiterable
  
      if level is not None:
          level += 1
  
      return func(obj, level)
docs: Covert any object to unicode string.
  
      :param obj: any object
      :type encoding: str
      :param encoding: codec for encoding unicode strings
                       (locale.getpreferredencoding() by default)
      :type level: int
      :param level: Deep level. If None level is not considered.
  
      :rtype: unicode
      :return: any object as unicode string