in opensearchpy/client/utils.py [0:0]
def _bulk_body(serializer, body):
# if not passed in a string, serialize items and join by newline
if not isinstance(body, string_types):
body = "\n".join(map(serializer.dumps, body))
# bulk body must end with a newline
if isinstance(body, bytes):
if not body.endswith(b"\n"):
body += b"\n"
elif isinstance(body, string_types) and not body.endswith("\n"):
body += "\n"
return body