# HG changeset patch # User Steve Borho # Date 2010-08-28 03:24:47 # Node ID a8b1cb0b0ddb63d32294d4e0edb464c7006275c7 # Parent 6449be7b8a3b96f06e7376f983035efcb189c30e color: handle more Windows console errors If your application is being built as a non-console application, stdout is not a valid handle and raises an exception: pywintypes.error: (6, 'DuplicateHandle', 'The handle is invalid.') Alternatively, non-console applications launched outside of a console will return None from GetStdHandle instead of raising an exception. diff --git a/hgext/color.py b/hgext/color.py --- a/hgext/color.py +++ b/hgext/color.py @@ -254,8 +254,10 @@ try: 'inverse': win32c.COMMON_LVB_REVERSE_VIDEO, # double-byte charsets only } - stdout = win32c.GetStdHandle(win32c.STD_OUTPUT_HANDLE) try: + stdout = win32c.GetStdHandle(win32c.STD_OUTPUT_HANDLE) + if stdout is None: + raise ImportError() origattr = stdout.GetConsoleScreenBufferInfo()['Attributes'] except pywintypes.error: # stdout may be defined but not support