← index #652Issue #5110
Related · high · value 0.738
QUERY · ISSUE

traceback.format_exc failed due to sys.exc_info not exist

openby zcattaczopened 2023-05-05updated 2024-09-25

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'
2 comments
andrewleech · 2023-05-05

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

nkrba · 2024-09-25

Thanks to @andrewleech, the above link worked!

try:
  ...
except Exception as exc:
  print_exception(exc)
CANDIDATE · ISSUE

Availability of sys.exc_info() in current builds

closedby amotlopened 2019-09-16updated 2019-09-17

Dear @pfalcon and the MicroPython community,

we recently received a pyboard-D and upgraded the firmware to the latest release so we are now running

MicroPython v1.11-312-g22099ab88 on 2019-09-15; PYBD-SF2W with STM32F722IEK

We are now aiming at porting our datalogger program [1] from Pycom MicroPython to the latest Genuine MicroPython coming from your pen.

However, we are having hard times figuring out why MicroPython croaks on this code

>>> import sys
>>> sys.exc_info()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'exc_info'

Does MicroPython just doesn't support sys.exc_info() at all or did we miss something differently?

Thanks in advance for taking the time to look at this issue.

With kind regards,
Andreas.

[1] https://github.com/hiveeyes/hiveeyes-micropython-firmware

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