Skip to content

Commit

Permalink
Fix additional encoding error (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
danyeaw authored Feb 12, 2024
1 parent f22ddb0 commit bfe1219
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/402.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix one additional encoding warning
7 changes: 6 additions & 1 deletion src/cleo/io/outputs/stream_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ def _get_utf8_support_info(self) -> bool:
"""
Returns whether the stream supports the UTF-8 encoding.
"""
encoding = self._stream.encoding or locale.getpreferredencoding(False)
if self._stream.encoding:
encoding = self._stream.encoding
elif sys.version_info < (3, 11):
encoding = locale.getpreferredencoding(False)
else:
encoding = locale.getencoding()

try:
return codecs.lookup(encoding).name == "utf-8"
Expand Down

0 comments on commit bfe1219

Please sign in to comment.