From d27e28754f7cf778e01c757c252fb683b0296962 Mon Sep 17 00:00:00 2001 From: Jonathan Slenders Date: Mon, 22 Jul 2024 09:23:21 +0000 Subject: [PATCH] Don't require 'exit' to be called with parentheses. --- ptpython/repl.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ptpython/repl.py b/ptpython/repl.py index b6fc0a5..6b60018 100644 --- a/ptpython/repl.py +++ b/ptpython/repl.py @@ -104,6 +104,11 @@ def run_and_show_expression(self, expression: str) -> None: except BaseException as e: self._handle_exception(e) else: + if isinstance(result, exit): + # When `exit` is evaluated without parentheses. + # Automatically trigger the `ReplExit` exception. + raise ReplExit + # Print. if result is not None: self._show_result(result)