Skip to content

Commit a771f63

Browse files
committed
Fixed bug where I was accidentally using a feature that is only available in Python 3.6
1 parent f4c3013 commit a771f63

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

cmd2.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,9 @@ def remaining_args(opts_plus_args, arg_list):
196196

197197
def _which(editor):
198198
try:
199+
editor_path = subprocess.check_output(['which', editor], stderr=subprocess.STDOUT).strip()
199200
if six.PY3:
200-
editor_path = subprocess.check_output(['which', editor], stderr=subprocess.STDOUT, encoding='utf-8').strip()
201-
else:
202-
editor_path = subprocess.check_output(['which', editor], stderr=subprocess.STDOUT).strip()
201+
editor_path = editor_path.decode()
203202
except subprocess.CalledProcessError:
204203
editor_path = None
205204
return editor_path
@@ -974,7 +973,6 @@ def do_help(self, arg):
974973
# Getting help for a specific command
975974
funcname = self._func_named(arg)
976975
if funcname:
977-
fn = getattr(self, funcname)
978976
# No special behavior needed, delegate to cmd base class do_help()
979977
cmd.Cmd.do_help(self, funcname[3:])
980978
else:
@@ -1602,7 +1600,7 @@ def do_save(self, arg):
16021600
f.close()
16031601
self.pfeedback('Saved to {}'.format(fname))
16041602
except Exception as e:
1605-
self.perror('Saving {!r} - {}'.format(fname, e.strerror), traceback_war=False)
1603+
self.perror('Saving {!r} - {}'.format(fname, e), traceback_war=False)
16061604

16071605
def do__relative_load(self, file_path):
16081606
"""Runs commands in script file that is encoded as either ASCII or UTF-8 text.

0 commit comments

Comments
 (0)