diff --git a/HISTORY.rst b/HISTORY.rst index 858f102c..9addc2bf 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -15,6 +15,8 @@ PlatformIO Core 5 * Improved listing of `multicast DNS services `_ * Check for debug server's "ready_pattern" in "stderr" * Upgraded build engine to the SCons 4.1 (`release notes `_) +* Fixed a "UnicodeDecodeError: 'utf-8' codec can't decode byte" when using J-Link for a firmware uploading on Linux (`issue #3804 `_) +* Fixed an issue with Python 3.8+ on Windows when network drive is used (`issue #3417 `_) 5.0.4 (2020-12-30) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/proc.py b/platformio/proc.py index d9df0a3b..24640c38 100644 --- a/platformio/proc.py +++ b/platformio/proc.py @@ -32,7 +32,10 @@ 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) + if PY2: + self._pipe_reader = os.fdopen(self._fd_read) + else: + self._pipe_reader = os.fdopen(self._fd_read, errors="backslashreplace") self._buffer = "" self._thread = Thread(target=self.run) self._thread.start() @@ -68,10 +71,10 @@ class BuildAsyncPipe(AsyncPipeBase): line = "" print_immediately = False - for byte in iter(lambda: self._pipe_reader.read(1), ""): - self._buffer += byte + for char in iter(lambda: self._pipe_reader.read(1), ""): + self._buffer += char - if line and byte.strip() and line[-3:] == (byte * 3): + if line and char.strip() and line[-3:] == (char * 3): print_immediately = True if print_immediately: @@ -79,12 +82,12 @@ class BuildAsyncPipe(AsyncPipeBase): if line: self.data_callback(line) line = "" - self.data_callback(byte) - if byte == "\n": + self.data_callback(char) + if char == "\n": print_immediately = False else: - line += byte - if byte != "\n": + line += char + if char != "\n": continue self.line_callback(line) line = ""