diff --git a/news/402.misc.md b/news/402.misc.md new file mode 100644 index 00000000..f4d5d9d2 --- /dev/null +++ b/news/402.misc.md @@ -0,0 +1 @@ +Fix one additional encoding warning diff --git a/src/cleo/io/outputs/stream_output.py b/src/cleo/io/outputs/stream_output.py index 39bdd65f..200fff38 100644 --- a/src/cleo/io/outputs/stream_output.py +++ b/src/cleo/io/outputs/stream_output.py @@ -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"