def dumps()

in elastic_transport/_serializer.py [0:0]


    def dumps(self, data: str) -> bytes:
        # The body is already encoded to bytes
        # so we forward the request body along.
        if isinstance(data, bytes):
            return data
        try:
            return data.encode("utf-8", "surrogatepass")
        except (AttributeError, UnicodeError, TypeError) as e:
            raise SerializationError(
                f"Unable to serialize to text: {data!r}", errors=(e,)
            )