win32: win32console.GetStdHandle() can return None stable
authorSteve Borho <steve@borho.org>
Fri, 21 Jan 2011 14:42:15 -0600
branchstable
changeset 13285 2ef915184ff2
parent 13249 75d0c38a0bca
child 13286 189edd1b15fb
child 13287 d0e0d3d43e14
win32: win32console.GetStdHandle() can return None When the Mercurial Python libraries are used within a Windows application with no console, there is no stderr file handle.
mercurial/win32.py
--- a/mercurial/win32.py	Sun Jan 09 00:35:36 2011 +0900
+++ b/mercurial/win32.py	Fri Jan 21 14:42:15 2011 -0600
@@ -170,6 +170,8 @@
     try:
         # Query stderr to avoid problems with redirections
         screenbuf = win32console.GetStdHandle(win32console.STD_ERROR_HANDLE)
+        if screenbuf is None:
+            return 79
         try:
             window = screenbuf.GetConsoleScreenBufferInfo()['Window']
             width = window.Right - window.Left