diff --git a/HISTORY.rst b/HISTORY.rst index 4b172830..07021307 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,7 +18,7 @@ PlatformIO Core 5 - Fixed an issue when the ``$PROJECT_DIR`` variable was not properly replaced in the `debug_server `__ option (`issue #4086 `_) - Fixed an issue when `PIO Remote `__ device monitor crashes on the first keypress (`issue #3832 `_) - Fixed "Do not know how to make File target 'debug'" issue when debugging project using `CLion IDE `__ (`pull #4089 `_) - +- Fixed "UnicodeEncodeError" when a build output contains non-ASCII characters (`issue #3971 `_) 5.2.2 (2021-10-20) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/platform/_run.py b/platformio/platform/_run.py index 09642689..00588c5a 100644 --- a/platformio/platform/_run.py +++ b/platformio/platform/_run.py @@ -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( diff --git a/platformio/proc.py b/platformio/proc.py index 0484cc42..f041d61c 100644 --- a/platformio/proc.py +++ b/platformio/proc.py @@ -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()