Exit the ptpython REPL.
| 493 | |
| 494 | |
| 495 | class exit: |
| 496 | """ |
| 497 | Exit the ptpython REPL. |
| 498 | """ |
| 499 | |
| 500 | # This custom exit function ensures that the `embed` function returns from |
| 501 | # where we are embedded, and Python doesn't close `sys.stdin` like |
| 502 | # the default `exit` from `_sitebuiltins.Quitter` does. |
| 503 | |
| 504 | def __call__(self) -> NoReturn: |
| 505 | raise ReplExit |
| 506 | |
| 507 | def __repr__(self) -> str: |
| 508 | # (Same message as the built-in Python REPL.) |
| 509 | return "Use exit() or Ctrl-D (i.e. EOF) to exit" |
| 510 | |
| 511 | |
| 512 | class ReplExit(Exception): |