Skip to content

Commit

Permalink
Check return value from GetConsoleMode/SetConsoleMode
Browse files Browse the repository at this point in the history
  • Loading branch information
njsmith committed Aug 25, 2022
1 parent 7d3d3b9 commit 7ec896d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion colorama/win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ def GetConsoleMode(stream_id):
handle = _GetStdHandle(stream_id)
mode = wintypes.DWORD()
success = _GetConsoleMode(handle, byref(mode))
if not success:
raise ctypes.WinError()
return mode.value

def SetConsoleMode(stream_id, mode):
handle = _GetStdHandle(stream_id)
return _SetConsoleMode(handle, mode)
success = _SetConsoleMode(handle, mode)
if not success:
raise ctypes.WinError()

0 comments on commit 7ec896d

Please sign in to comment.