Commit 96d13ae 1 parent bb97a05 commit 96d13ae Copy full SHA for 96d13ae
File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ def __init__(
17
17
service_url : str ,
18
18
truss_handle : Optional [TrussHandle ] = None ,
19
19
):
20
-
21
20
super ().__init__ (is_draft = is_draft , service_url = service_url )
22
21
self ._model_id = model_id
23
22
self ._model_version_id = model_version_id
@@ -43,7 +42,13 @@ def decode_content():
43
42
for chunk in response .iter_content (
44
43
chunk_size = 8192 , decode_unicode = True
45
44
):
46
- yield chunk .decode (response .encoding or DEFAULT_STREAM_ENCODING )
45
+ # Depending on the content-type of the response,
46
+ # iter_content will either emit a byte stream, or a stream
47
+ # of strings. Only decode in the bytes case.
48
+ if isinstance (chunk , bytes ):
49
+ yield chunk .decode (response .encoding or DEFAULT_STREAM_ENCODING )
50
+ else :
51
+ yield chunk
47
52
48
53
return decode_content ()
49
54
You can’t perform that action at this time.
0 commit comments