(self, s, insert_into_history=True)
| 927 | self.echo(s) |
| 928 | |
| 929 | def push(self, s, insert_into_history=True): |
| 930 | # Restore the original SIGINT handler. This is needed to be able |
| 931 | # to break out of infinite loops. If the interpreter itself |
| 932 | # sees this it prints 'KeyboardInterrupt' and returns (good). |
| 933 | orig_handler = signal.getsignal(signal.SIGINT) |
| 934 | signal.signal(signal.SIGINT, signal.default_int_handler) |
| 935 | # Pretty blindly adapted from bpython.cli |
| 936 | try: |
| 937 | return super().push(s, insert_into_history) |
| 938 | except SystemExit as e: |
| 939 | self.exit_value = e.args |
| 940 | raise urwid.ExitMainLoop() |
| 941 | except KeyboardInterrupt: |
| 942 | # KeyboardInterrupt happened between the except block around |
| 943 | # user code execution and this code. This should be rare, |
| 944 | # but make sure to not kill bpython here, so leaning on |
| 945 | # ctrl+c to kill buggy code running inside bpython is safe. |
| 946 | self.keyboard_interrupt() |
| 947 | finally: |
| 948 | signal.signal(signal.SIGINT, orig_handler) |
| 949 | |
| 950 | def start(self): |
| 951 | self.prompt(False) |
no test coverage detected