From 1ccbe2f4464abd7627f6b260280f09a652d64f82 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Fri, 12 Jul 2024 23:37:28 -0400 Subject: [PATCH 1/4] Update Standard Library sys documentation --- docs/library/sys.rst | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/library/sys.rst b/docs/library/sys.rst index c77f9a1c57be..4091232c8f53 100644 --- a/docs/library/sys.rst +++ b/docs/library/sys.rst @@ -15,6 +15,21 @@ Functions function raise as `SystemExit` exception. If an argument is given, its value given as an argument to `SystemExit`. +.. function:: print_exception(exc, file=sys.stdout, /) + + Print exception with a traceback to a file-like object *file* (or + `sys.stdout` by default). + + .. admonition:: Difference to CPython + :class: attention + + This is simplified version of a function which appears in the + ``traceback`` module in CPython. Unlike ``traceback.print_exception()``, + this function takes just exception value instead of exception type, + exception value, and traceback object; *file* argument should be + positional; further arguments are not supported. CPython-compatible + ``traceback`` module can be found in `micropython-lib`. + Constants --------- @@ -97,12 +112,6 @@ Constants If you need to check whether your program runs on CircuitPython (vs other Python implementation), use `sys.implementation` instead. -.. data:: ps1 - ps2 - - Mutable attributes holding strings, which are used for the REPL prompt. The defaults - give the standard Python prompt of ``>>>`` and ``...``. - .. data:: stderr Standard error ``stream``. @@ -115,14 +124,6 @@ Constants Standard output ``stream``. -.. data:: tracebacklimit - - A mutable attribute holding an integer value which is the maximum number of traceback - entries to store in an exception. Set to 0 to disable adding tracebacks. Defaults - to 1000. - - Note: this is not available on all ports. - .. data:: version Python language version that this implementation conforms to, as a string. From 95cf8b6b7bb09cf4d08e34adc9167afe4a5494e1 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Mon, 15 Jul 2024 13:36:22 -0400 Subject: [PATCH 2/4] Remove reference to micropython-lib --- docs/library/sys.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/library/sys.rst b/docs/library/sys.rst index 4091232c8f53..1eb7103d57a0 100644 --- a/docs/library/sys.rst +++ b/docs/library/sys.rst @@ -27,8 +27,7 @@ Functions ``traceback`` module in CPython. Unlike ``traceback.print_exception()``, this function takes just exception value instead of exception type, exception value, and traceback object; *file* argument should be - positional; further arguments are not supported. CPython-compatible - ``traceback`` module can be found in `micropython-lib`. + positional; further arguments are not supported. Constants --------- From 38258228333893d1c456ccbe9c2fc135a278fafd Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 22 Jul 2024 15:44:39 -0500 Subject: [PATCH 3/4] Use single backticks to create links .. so that the reader of the documentation can readily get to the `traceback.print_exception` docs --- docs/library/sys.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/library/sys.rst b/docs/library/sys.rst index 1eb7103d57a0..1b25036c7172 100644 --- a/docs/library/sys.rst +++ b/docs/library/sys.rst @@ -24,7 +24,7 @@ Functions :class: attention This is simplified version of a function which appears in the - ``traceback`` module in CPython. Unlike ``traceback.print_exception()``, + `traceback` module in CPython. Unlike `traceback.print_exception()`, this function takes just exception value instead of exception type, exception value, and traceback object; *file* argument should be positional; further arguments are not supported. From 01fb9de802ee490829962cd87015296e73149be5 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Mon, 22 Jul 2024 22:54:13 -0400 Subject: [PATCH 4/4] Add depreciation warning for sys.print_exception --- docs/library/sys.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/library/sys.rst b/docs/library/sys.rst index 1b25036c7172..fd37f2abd27d 100644 --- a/docs/library/sys.rst +++ b/docs/library/sys.rst @@ -17,6 +17,9 @@ Functions .. function:: print_exception(exc, file=sys.stdout, /) + This function is being deprecated and will be removed starting in + CircuitPython 10.x, `traceback.print_exception()` should be used instead. + Print exception with a traceback to a file-like object *file* (or `sys.stdout` by default).