+2024-05-15 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Don't print tracebacks when Ctrl-C is pressed.
+ Suggested by Pádraig Brady in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00200.html>.
+ * pygnulib/main.py (cli_exception): New function.
+ (main_with_exception_handling): Use it.
+
2024-05-15 Bruno Haible <bruno@clisp.org>
stdbit-h: Add tests.
pass
+def cli_exception(exc_type, exc_value, exc_traceback) -> None:
+ '''Exception hook that does not print a traceback for KeyboardInterrupts
+ thrown when Ctrl-C is pressed.'''
+ if not issubclass(exc_type, KeyboardInterrupt):
+ sys.__excepthook__(exc_type, exc_value, exc_traceback)
+
+
def main_with_exception_handling() -> None:
+ # Don't print tracebacks for KeyboardInterrupts when stdin is a tty.
+ if sys.stdin and sys.stdin.isatty():
+ sys.excepthook = cli_exception
+
try: # Try to execute
with tempfile.TemporaryDirectory(prefix='glpy') as temporary_directory:
main(temporary_directory)