Skip to content

sys: remove nonstandard print_exception #9446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions docs/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,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``.
Expand All @@ -115,14 +109,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.
Expand Down
2 changes: 2 additions & 0 deletions py/circuitpy_mpconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ extern void common_hal_mcu_enable_interrupts(void);
#define MICROPY_PY_SYS (CIRCUITPY_SYS)
#define MICROPY_PY_SYS_MAXSIZE (1)
#define MICROPY_PY_SYS_STDFILES (1)
// Supplanted by traceback.print_exception
#define MICROPY_PY_SYS_PRINT_EXCEPTION (0)
#define MICROPY_PY___FILE__ (1)

#define MICROPY_QSTR_BYTES_IN_HASH (1)
Expand Down
3 changes: 3 additions & 0 deletions py/modsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
* Extensions to CPython
*/

#if MICROPY_PY_SYS_PRINT_EXCEPTION
{ MP_ROM_QSTR(MP_QSTR_print_exception), MP_ROM_PTR(&mp_sys_print_exception_obj) },
#endif

#if MICROPY_PY_SYS_ATEXIT
{ MP_ROM_QSTR(MP_QSTR_atexit), MP_ROM_PTR(&mp_sys_atexit_obj) },
#endif
Expand Down
5 changes: 5 additions & 0 deletions py/mpconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,11 @@ typedef double mp_float_t;
#define MICROPY_PY_SYS_EXIT (1)
#endif

// Whether to provide "sys.print_exception" function (MicroPython extension)
#ifndef MICROPY_PY_SYS_PRINT_EXCEPTION
#define MICROPY_PY_SYS_PRINT_EXCEPTION (1)
#endif

// Whether to provide "sys.atexit" function (MicroPython extension)
#ifndef MICROPY_PY_SYS_ATEXIT
#define MICROPY_PY_SYS_ATEXIT (0)
Expand Down