Windows Module

Error handling for expected / unexpected exceptions on Windows systems.

cli_command_parser.error_handling.windows.handle_kb_interrupt(exc: KeyboardInterrupt) int[source]

Handles KeyboardInterrupt by calling print() to avoid ending the program in a way that causes the next terminal prompt to be printed on the same line as the last (possibly incomplete) line of output.

cli_command_parser.error_handling.windows.handle_win_os_pipe_error(exc: OSError)[source]

This is a workaround for [Windows] I/O on a broken pipe may raise an EINVAL OSError instead of BrokenPipeError, which is a bug in the way that the Windows error code for a broken pipe is translated into an errno value. It should be translated to EPIPE, but it uses EINVAL (22) instead.

Prevents the following when piping output to utilities such as | head:

Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
OSError: [Errno 22] Invalid argument