Skip to content
Snippets Groups Projects
Commit 65beae09 authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Properly prevent sending XML files opened in text mode

parent ce528f8c
No related branches found
No related tags found
No related merge requests found
Pipeline #28222 canceled
...@@ -8,7 +8,7 @@ import yaml ...@@ -8,7 +8,7 @@ import yaml
from arkindex.auth import TokenSessionAuthentication from arkindex.auth import TokenSessionAuthentication
from arkindex.pagination import ResponsePaginator from arkindex.pagination import ResponsePaginator
from arkindex.encoders import XMLEncoder from arkindex.encoders import XMLEncoder
from io import FileIO from io import IOBase, BufferedIOBase
from time import sleep from time import sleep
from urllib.parse import urlsplit, urlunsplit from urllib.parse import urlsplit, urlunsplit
...@@ -183,8 +183,8 @@ class ArkindexClient(apistar.Client): ...@@ -183,8 +183,8 @@ class ArkindexClient(apistar.Client):
:param kwargs: Other arguments sent to :meth:`ArkindexClient.custom_request`. :param kwargs: Other arguments sent to :meth:`ArkindexClient.custom_request`.
""" """
if isinstance(body, FileIO): if isinstance(body, IOBase):
assert body.mode == 'rb', 'File-like objects should be opened in binary mode' assert isinstance(body, BufferedIOBase), 'File-like objects should be opened in binary mode'
return self.custom_request( return self.custom_request(
operation_id, operation_id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment