From: W. Trevor King Date: Fri, 29 Jan 2010 12:32:41 +0000 (-0500) Subject: Fix editor spawning on null-string EDITOR and VISUAL. X-Git-Tag: 1.0.0~59^2~25 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=12a948ddf009fb2510eda5be4f576dc3e7de401f;p=be.git Fix editor spawning on null-string EDITOR and VISUAL. $ EDITOR= VISUAL= python -c 'import os; import sys; print os.environ' {..., 'EDITOR': '', ..., 'VISUAL': '', ...} --- diff --git a/libbe/ui/util/editor.py b/libbe/ui/util/editor.py index ce14365..1a430c7 100644 --- a/libbe/ui/util/editor.py +++ b/libbe/ui/util/editor.py @@ -64,13 +64,12 @@ def editor_string(comment=None, encoding=None): """ if encoding == None: encoding = libbe.util.encoding.get_filesystem_encoding() + editor = None for name in ('VISUAL', 'EDITOR'): - try: + if name in os.environ and os.environ[name] != '': editor = os.environ[name] break - except KeyError: - pass - else: + if editor == None: raise CantFindEditor() fhandle, fname = tempfile.mkstemp() try: