From 8ba9094a1838c29afd09ef3547f33e17c90a060e 2013-12-02 21:06:44 From: Thomas Kluyver Date: 2013-12-02 21:06:44 Subject: [PATCH] Fall back to default editor if $EDITOR is non-ASCII. Closes gh-4615 --- diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py index 9297c70..4f72ee5 100644 --- a/IPython/terminal/interactiveshell.py +++ b/IPython/terminal/interactiveshell.py @@ -41,13 +41,19 @@ from IPython.utils.traitlets import Integer, CBool, Unicode def get_default_editor(): try: ed = os.environ['EDITOR'] + if not py3compat.PY3: + ed = ed.decode() + return ed except KeyError: - if os.name == 'posix': - ed = 'vi' # the only one guaranteed to be there! - else: - ed = 'notepad' # same in Windows! - return ed - + pass + except UnicodeError: + warn("$EDITOR environment variable is not pure ASCII. Using platform " + "default editor.") + + if os.name == 'posix': + return 'vi' # the only one guaranteed to be there! + else: + return 'notepad' # same in Windows! def get_pasted_lines(sentinel, l_input=py3compat.input): """ Yield pasted lines until the user enters the given sentinel value.