micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

traceback.format_exc failed due to sys.exc_info not exist

Open zcattacz opened this issue 2 years ago • 2 comments

Is this expected? not design to work on MCU ports ?

>>> try:
...     1/0
... except:
...     print(traceback.format_exc())
...     
...     
... 
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "traceback.py", line 27, in format_exc
AttributeError: 'module' object has no attribute 'exc_info'

zcattacz avatar May 05 '23 08:05 zcattacz

I'm not sure, I haven't tried the traceback module from here it might be out of date.

Take a look at this, it might be what you want: https://docs.micropython.org/en/latest/library/sys.html#sys.print_exception

andrewleech avatar May 05 '23 10:05 andrewleech

Thanks to @andrewleech, the above link worked!

try:
  ...
except Exception as exc:
  print_exception(exc)

nkrba avatar Sep 25 '24 11:09 nkrba