From c5d74fe46876767cc43d7d23d949d0f7c3dcd6bd Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 8 Oct 2024 14:41:44 +1100 Subject: [PATCH] docs/library: Note link between machine.soft_reset() and sys.exit(). This is currently an implementation detail of MicroPython rather than by design. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton --- docs/library/builtins.rst | 6 ++++++ docs/library/sys.rst | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/library/builtins.rst b/docs/library/builtins.rst index 88b1fbcfe..5956aea7a 100644 --- a/docs/library/builtins.rst +++ b/docs/library/builtins.rst @@ -194,6 +194,12 @@ Exceptions |see_cpython| `python:SystemExit`. + On non-embedded ports (i.e. Windows and Unix), an unhandled ``SystemExit`` + exits the MicroPython process in a similar way to CPython. + + On embedded ports, an unhandled ``SystemExit`` currently causes a + :ref:`soft_reset` of MicroPython. + .. exception:: TypeError |see_cpython| `python:TypeError`. diff --git a/docs/library/sys.rst b/docs/library/sys.rst index 7b34a0e31..c72214c13 100644 --- a/docs/library/sys.rst +++ b/docs/library/sys.rst @@ -12,9 +12,12 @@ Functions .. function:: exit(retval=0, /) Terminate current program with a given exit code. Underlyingly, this - function raise as `SystemExit` exception. If an argument is given, its + function raises a `SystemExit` exception. If an argument is given, its value given as an argument to `SystemExit`. + On embedded ports (i.e. all ports but Windows and Unix), an unhandled + `SystemExit` currently causes a :ref:`soft_reset` of MicroPython. + .. function:: atexit(func) Register *func* to be called upon termination. *func* must be a callable