Skip to content

Commit

Permalink
FIX: guess_stream_needs_encoding must return False when fileobj is an…
Browse files Browse the repository at this point in the history
… instance of io.TextIOBase, because fileobj.write needs a str as parameter, not bytes
  • Loading branch information
Sylvain Ferriol committed Dec 18, 2023
1 parent 50a111a commit 14751de
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions txaio/_iotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ def guess_stream_needs_encoding(fileobj, default=True):
except Exception:
pass

try:
import io
return not isinstance(fileobj, io.TextIOBase)
except Exception:
pass

return default

0 comments on commit 14751de

Please sign in to comment.