Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esp8266ExceptionDecoder: fix crash on Windows with Python <3;3.7> #201

Merged
merged 1 commit into from
Mar 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions monitor/filter_exception_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import sys

from platformio.commands.device import DeviceMonitorFilter
from platformio.compat import get_filesystem_encoding, path_to_unicode
from platformio.compat import path_to_unicode, WINDOWS, PY2
from platformio.project.exception import PlatformioException
from platformio.project.helpers import load_project_ide_data

Expand Down Expand Up @@ -251,18 +251,24 @@ def take_stack_lines(self):

def get_lines(self, addresses):
result = []
enc = get_filesystem_encoding()
args = (self.addr2line_path, "-fipC", "-e", self.firmware_path)
args = [a.encode(enc) for a in args]

enc = "mbcs" if WINDOWS else "utf-8"
args = [self.addr2line_path, u"-fipC", u"-e", self.firmware_path]
if PY2:
args = [a.encode(enc) for a in args]

for addr in addresses:
if not self.is_addr_ok(addr):
result.append(None)
continue

if PY2:
addr = addr.encode(enc)

to_append = None
try:
output = (
subprocess.check_output(args + [addr.encode(enc)])
subprocess.check_output(args + [addr])
.decode(enc)
.strip()
)
Expand Down