Fixed "UnicodeEncodeError" when a build output contains non-ASCII characters // Resolve #3971

This commit is contained in:
Ivan Kravets
2021-10-25 22:01:11 +03:00
parent d7b7d2de6e
commit c835ce780a
3 changed files with 6 additions and 2 deletions

View File

@ -18,7 +18,7 @@ PlatformIO Core 5
- Fixed an issue when the ``$PROJECT_DIR`` variable was not properly replaced in the `debug_server <https://docs.platformio.org/page/projectconf/section_env_debug.html#debug-server>`__ option (`issue #4086 <https://github.com/platformio/platformio-core/issues/4086>`_)
- Fixed an issue when `PIO Remote <https://docs.platformio.org/page/plus/pio-remote.html>`__ device monitor crashes on the first keypress (`issue #3832 <https://github.com/platformio/platformio-core/issues/3832>`_)
- Fixed "Do not know how to make File target 'debug'" issue when debugging project using `CLion IDE <https://docs.platformio.org/page/integration/ide/clion.html>`__ (`pull #4089 <https://github.com/platformio/platformio-core/issues/4089>`_)
- Fixed "UnicodeEncodeError" when a build output contains non-ASCII characters (`issue #3971 <https://github.com/platformio/platformio-core/issues/3971>`_)
5.2.2 (2021-10-20)
~~~~~~~~~~~~~~~~~~

View File

@ -110,6 +110,8 @@ class PlatformRunMixin(object):
args.append("%s=%s" % (key.upper(), self.encode_scons_arg(value)))
proc.copy_pythonpath_to_osenv()
# force SCons output to Unicode
os.environ["PYTHONIOENCODING"] = "utf-8"
if targets and "menuconfig" in targets:
return proc.exec_command(

View File

@ -30,7 +30,9 @@ from platformio.compat import (
class AsyncPipeBase(object):
def __init__(self):
self._fd_read, self._fd_write = os.pipe()
self._pipe_reader = os.fdopen(self._fd_read, errors="backslashreplace")
self._pipe_reader = os.fdopen(
self._fd_read, encoding="utf-8", errors="backslashreplace"
)
self._buffer = ""
self._thread = Thread(target=self.run)
self._thread.start()