Skip to content

Commit 3cb0154

Browse files
committed
Catch "UnicodeDecodeError" when outputting process result // Resolve platformio#56
1 parent 1f1d357 commit 3cb0154

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

get-platformio.py

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pioinstaller/python.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def check():
135135
return True
136136

137137

138-
def find_compatible_pythons(ignore_pythons=None):
138+
def find_compatible_pythons(ignore_pythons=None): # pylint: disable=too-many-branches
139139
ignore_list = []
140140
for p in ignore_pythons or []:
141141
ignore_list.extend(glob.glob(p))
@@ -171,9 +171,17 @@ def find_compatible_pythons(ignore_pythons=None):
171171
stderr=subprocess.STDOUT,
172172
)
173173
result.append(item)
174-
log.debug(output.decode().strip())
174+
try:
175+
log.debug(output.decode().strip())
176+
except UnicodeDecodeError:
177+
pass
175178
except subprocess.CalledProcessError as e: # pylint:disable=bare-except
176-
error = e.output.decode()
179+
try:
180+
error = e.output.decode()
181+
log.debug(error)
182+
except UnicodeDecodeError:
183+
pass
184+
error = error or ""
177185
if "Could not find distutils module" in error:
178186
# pylint:disable=line-too-long
179187
raise click.ClickException(
@@ -184,5 +192,4 @@ def find_compatible_pythons(ignore_pythons=None):
184192
185193
(MAY require administrator access `sudo`)""",
186194
)
187-
log.debug(error)
188195
return result

0 commit comments

Comments
 (0)