Skip to content

Commit b5db939

Browse files
authored
Esp8266ExceptionDecoder: fix crash on Windows with Python <3;3.7> (#201)
1 parent f81f371 commit b5db939

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

monitor/filter_exception_decoder.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import sys
1919

2020
from platformio.commands.device import DeviceMonitorFilter
21-
from platformio.compat import get_filesystem_encoding, path_to_unicode
21+
from platformio.compat import path_to_unicode, WINDOWS, PY2
2222
from platformio.project.exception import PlatformioException
2323
from platformio.project.helpers import load_project_ide_data
2424

@@ -251,18 +251,24 @@ def take_stack_lines(self):
251251

252252
def get_lines(self, addresses):
253253
result = []
254-
enc = get_filesystem_encoding()
255-
args = (self.addr2line_path, "-fipC", "-e", self.firmware_path)
256-
args = [a.encode(enc) for a in args]
254+
255+
enc = "mbcs" if WINDOWS else "utf-8"
256+
args = [self.addr2line_path, u"-fipC", u"-e", self.firmware_path]
257+
if PY2:
258+
args = [a.encode(enc) for a in args]
259+
257260
for addr in addresses:
258261
if not self.is_addr_ok(addr):
259262
result.append(None)
260263
continue
261264

265+
if PY2:
266+
addr = addr.encode(enc)
267+
262268
to_append = None
263269
try:
264270
output = (
265-
subprocess.check_output(args + [addr.encode(enc)])
271+
subprocess.check_output(args + [addr])
266272
.decode(enc)
267273
.strip()
268274
)

0 commit comments

Comments
 (0)