Closed Galunid closed 2 years ago
You're not calling traceback.print_exc
right. You would get the same error on CPython. Try it:
import traceback
try:
1/0
except Exception as e:
traceback.print_exc(e)
Outputs:
Traceback (most recent call last):
File "/home/msimacek/t.py", line 3, in <module>
1/0
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/msimacek/t.py", line 5, in <module>
traceback.print_exc(e)
File "/usr/lib64/python3.9/traceback.py", line 163, in print_exc
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
File "/usr/lib64/python3.9/traceback.py", line 103, in print_exception
for line in TracebackException(
File "/usr/lib64/python3.9/traceback.py", line 517, in __init__
self.stack = StackSummary.extract(
File "/usr/lib64/python3.9/traceback.py", line 340, in extract
if limit >= 0:
TypeError: '>=' not supported between instances of 'ZeroDivisionError' and 'int'
The correct way is either:
traceback.print_exc() # Implicitly takes the current caught exception
or
traceback.print_exception(type(e), e, e.__traceback__)
When I run the following python code:
I get the following log:
Happens in both
GraalVM Python 3.8.5 (GraalVM CE Native 22.1.0-dev)
andPython 3.8.5 (GraalVM CE Native 21.3.0)
. The first is in Manjaro Linux Virtual Machine, the latter in docker container.