Skip to content

Commit 5cbeaf7

Browse files
committed
handling of variable returned by subprocess more robust to different string types
1 parent d530b01 commit 5cbeaf7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

heudiconv/utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,14 @@ def dec(obj):
105105
def anonymize_sid(sid, anon_sid_cmd):
106106
from subprocess import check_output
107107
cmd = [anon_sid_cmd, sid]
108-
return check_output(cmd).decode().strip()
108+
shell_out = check_output(cmd).strip()
109+
if isinstance(shell_out, bytes):
110+
anon_sid = shell_out.decode()
111+
elif isinstance(shell_out, str):
112+
anon_sid = shell_out
113+
else:
114+
raise 'subprocess did not return a valid string'
115+
return anon_sid
109116

110117

111118
def create_file_if_missing(filename, content):

0 commit comments

Comments
 (0)