The interactive interpreter is overwriting the exit and quit builtins with an instance of LLDBQuitter in order to make exit and quit behave like exit() and quit(). It does that by overwriting the __repr__ function to call itself. Despite being a neat trick, it has the unintentional side effect that printing these builtins now quits the interpreter:
(lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> print(exit) (lldb)
You might consider the above example slightly convoluted, but a more realistic situation is calling locals():
(lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> locals() (lldb)
This patch keeps the existing behavior but without overwriting the builtins. Instead, it looks for quit and exit in the input and raises an appropriate exception. The previous implementation also used globals to differentiate between exit getting called from the interactive interpreter and from scripts. This patch makes use of a custom exception in order to do the same.
rdar://84095490
could do: