At startup, GDB overrides Pythonās sys.stdout and sys.stderr to print using GDB ās output-paging streams. A Python program which outputs to one of these streams may have its output interrupted by the user (see Screen Size). In this situation, a Python KeyboardInterrupt exception is thrown.
