← index #4667Issue #751
Related · high · value 4.773
QUERY · ISSUE

Print traceback without an exception

openby mzakharocscopened 2019-04-02updated 2019-05-14

Hello, in CPython, there is a way to print a traceback outside of an exception, through traceback.print_stack() function. What would it take to add similar functionality to micropython?

CANDIDATE · ISSUE

Add way to print exception traceback

closedby pfalconopened 2014-07-13updated 2014-12-09

@dhylands mentioned recently that it's not possible to print exception traceback. So, let's add that. In CPython, it is handled by https://docs.python.org/3/library/traceback.html module, but it would be too heavy to add whole new module for such a trivial task, so let's implement it more lightweight, and allow traceback module be implemented in terms of it.

Then, there're 2 ways to do that: 1) add method to exception object; 2) add function to some existing module which will take exception as arg. 1) is definitely more OO, but has a problem that it may be not compliant due to possible conflict with user-defined exc attribute. For 2nd option, we can add something like sys.print_exception(exc, file=sys.stdout).

Thoughts?

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied