Skip to content

Commit b33f422

Browse files
committed
Merge branch 'fix/converter_decode' into 'master'
fix: correctly decode string type in ANSIColorConverter Closes IDFGH-11966 and IDFGH-11971 See merge request espressif/esp-idf-monitor!57
2 parents d60342d + 9e6791b commit b33f422

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

esp_idf_monitor/base/ansi_color_converter.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import re
77
import sys
8-
from io import TextIOBase
8+
from io import TextIOBase # noqa: F401
99
from typing import Any, Optional, TextIO, Union # noqa: F401
1010

1111
from .output_helpers import ANSI_NORMAL
@@ -68,8 +68,8 @@ def __init__(self, output=None, force_color=False):
6868
def _output_write(self, data): # type: (Union[str, bytes]) -> None
6969
try:
7070
if self.decode_output:
71-
data = self.decode_buffer + data # type: ignore
72-
self.output.write(data.decode()) # type: ignore
71+
self.decode_buffer += data # type: ignore
72+
self.output.write(self.decode_buffer.decode()) # type: ignore
7373
self.decode_buffer = b''
7474
else:
7575
self.output.write(data) # type: ignore
@@ -82,7 +82,6 @@ def _output_write(self, data): # type: (Union[str, bytes]) -> None
8282
# (garbage bytes, etc)
8383
pass
8484
except UnicodeDecodeError:
85-
self.decode_buffer += data # type: ignore
8685
if len(self.decode_buffer) > 4:
8786
# Multi-byte character contain up to 4 bytes and if buffer have more then 4 bytes
8887
# and still can not decode it we can just ignore some bytes

0 commit comments

Comments
 (0)