# HG changeset patch # User Matt Harbison # Date 1427826465 14400 # Node ID 1818d4dca75cb0938a5c7ffd690541e5027c8e2e # Parent 1925769b4ff831a91325601a8a2cccdf7d3183ea color: fix crash in cmd.exe When 'term' is None because it isn't in the environment, don't iterate over it. Unfortunately, unsetting $TERM or exporting it as '' doesn't work in the tests, so there's no way to simulate cmd.exe in the test suite. diff -r 1925769b4ff8 -r 1818d4dca75c hgext/color.py --- a/hgext/color.py Wed Mar 18 21:44:25 2015 -0700 +++ b/hgext/color.py Tue Mar 31 14:27:45 2015 -0400 @@ -234,8 +234,6 @@ if os.name == 'nt': term = os.environ.get('TERM') # TERM won't be defined in a vanilla cmd.exe environment. - if not term: - realmode = 'win32' # UNIX-like environments on Windows such as Cygwin and MSYS will # set TERM. They appear to make a best effort attempt at setting it @@ -244,7 +242,7 @@ # gibberish, we error on the side of selecting "win32". However, if # w32effects is not defined, we almost certainly don't support # "win32", so don't even try. - if 'xterm' in term or not w32effects: + if (term and 'xterm' in term) or not w32effects: realmode = 'ansi' else: realmode = 'win32'