docs: def as_unicode(obj):
      """
      Safely casts any object to unicode including regular string
      (i.e. bytes) types in python 2.
      """
      if sys.version_info.major < 3 and isinstance(obj, str):
          obj = obj.decode('utf-8')
      return unicode(obj)