From 27df4e20dace7bed4a9891c024eadfaf0ce93b4a Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Fri, 7 Dec 2012 22:31:48 +0100 Subject: [PATCH] Add error handling for screen console function. --- linkcheck/colorama.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linkcheck/colorama.py b/linkcheck/colorama.py index 9adefe98..14b2c9a6 100644 --- a/linkcheck/colorama.py +++ b/linkcheck/colorama.py @@ -32,7 +32,7 @@ STDOUT = -11 STDERR = -12 from ctypes import (windll, byref, Structure, c_char, c_short, c_uint32, - c_ushort, ArgumentError) + c_ushort, ArgumentError, WinError) handles = { STDOUT: windll.kernel32.GetStdHandle(STDOUT), @@ -85,6 +85,8 @@ def GetConsoleScreenBufferInfo(stream_id=STDOUT): csbi = CONSOLE_SCREEN_BUFFER_INFO() success = windll.kernel32.GetConsoleScreenBufferInfo( handle, byref(csbi)) + if not success: + raise WinError() return csbi