From e9baa6236f9e31ec28ed159003a8be7de9adb973 Mon Sep 17 00:00:00 2001 From: dblock Date: Tue, 7 Nov 2023 13:27:41 -0500 Subject: [PATCH] Fixed TestBulk::test_bulk_works_with_bytestring_body. Signed-off-by: dblock --- opensearchpy/client/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opensearchpy/client/utils.py b/opensearchpy/client/utils.py index d2196d11..0663fd1d 100644 --- a/opensearchpy/client/utils.py +++ b/opensearchpy/client/utils.py @@ -187,15 +187,15 @@ def _wrapped(*args: Any, **kwargs: Any) -> Any: def _bulk_body(serializer: Optional[Serializer], body: Any) -> Any: # if not passed in a string, serialize items and join by newline - if serializer and not isinstance(body, str): - body = "\n".join(map(serializer.dumps, body)) + if not isinstance(body, string_types): + body = "\n".join(map(serializer.dumps, body)) # type: ignore # bulk body must end with a newline if isinstance(body, bytes): if not body.endswith(b"\n"): body += b"\n" - elif isinstance(body, str) and not body.endswith("\n"): - body += "\n" + elif isinstance(body, string_types) and not body.endswith("\n"): # type: ignore + body += "\n" # type: ignore return body