Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there runtime errors(= exceptions) that do not generate a traceback in python?

Are there runtime errors(= exceptions) that do not generate a traceback? If yes, why do some runtime errors not generate tracebacks? could you give some examples?

like image 270
Bentley4 Avatar asked Sep 19 '26 22:09

Bentley4


2 Answers

You can pass a very large value to sys.setrecursionlimit(), then enter an infinite recursive loop. The interpreter will crash without a traceback in that case.

However, that's only because the call to setrecursionlimit() effectively disables the fail-safe mechanism that would have turned a potential stack overflow into a Python exception.

like image 196
Frédéric Hamidi Avatar answered Sep 21 '26 13:09

Frédéric Hamidi


Yes, I can think of at least one: segmentation faults.

>>> import faulthandler
>>> faulthandler._sigsegv()
Segmentation fault

The faulthandler module is specifically designed to help in such situations.

>>> import faulthandler
>>> faulthandler.enable()
>>> faulthandler._sigsegv()
Fatal Python error: Segmentation fault

Current thread 0xb76fe6c0
 File "<stdin>", line 1 in <module>
Segmentation fault
like image 21
Andrew Walker Avatar answered Sep 21 '26 11:09

Andrew Walker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!