Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for 3.6 with locale not set #4038

Merged
merged 1 commit into from
Nov 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions poetry/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from cleo.io.outputs.output import Output

from poetry.__version__ import __version__
from poetry.core.utils._compat import PY37

from .command_loader import CommandLoader
from .commands.command import Command
Expand Down Expand Up @@ -143,6 +144,20 @@ def create_io(
) -> IO:
io = super().create_io(input, output, error_output)

# Remove when support for Python 3.6 is removed
# https://github.com/python-poetry/poetry/issues/3412
if (
not PY37
and hasattr(io.output, "_stream")
and hasattr(io.output._stream, "buffer")
and io.output._stream.encoding != "utf-8"
):
import io as io_

io.output._stream = io_.TextIOWrapper(
io.output._stream.buffer, encoding="utf-8"
)

# Set our own CLI styles
formatter = io.output.formatter
formatter.set_style("c1", Style("cyan"))
Expand Down