docs: def to_bytes(obj):
      """Ensures that the obj is of byte-type.
      """
  
      if PY3:
          if isinstance(obj, str):
              return obj.encode(settings.DEFAULT_ENCODING)
          else:
              return obj if isinstance(obj, bytes) else b''
      else:
          if isinstance(obj, str):
              return obj
          else:
              return obj.encode(settings.DEFAULT_ENCODING) if isinstance(obj, unicode) else ''