ipython: IPython crash when use showtraceback with exception_only=True
Used IPython version: 7.20.0-py38hd4e2768_1
The following exception was raised:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 1103, in get_records
return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
File "C:\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 248, in wrapped
return f(*args, **kwargs)
File "C:\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 281, in _fixed_getinnerframes
records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
File "C:\Anaconda3\lib\inspect.py", line 1503, in getinnerframes
frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
AttributeError: 'tuple' object has no attribute 'tb_frame'
And when this exception is caught in IPython.core.ultratb.VerboseTB.get_records, the return value is None:
def get_records(self, etb, number_of_lines_of_context, tb_offset):
try:
# Try the default getinnerframes and Alex's: Alex's fixes some
# problems, but it generates empty tracebacks for console errors
# (5 blanks lines) where none should be returned.
return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
except UnicodeDecodeError:
# This can occur if a file's encoding magic comment is wrong.
# I can't see a way to recover without duplicating a bunch of code
# from the stdlib traceback module. --TK
error('\nUnicodeDecodeError while processing traceback.\n')
return None
**except:
# FIXME: I've been getting many crash reports from python 2.3
# users, traceable to inspect.py. If I can find a small test-case
# to reproduce this, I should either write a better workaround or
# file a bug report against inspect (if that's the real problem).
# So far, I haven't been able to find an isolated example to
# reproduce the problem.
inspect_error()
traceback.print_exc(file=self.ostream)
info('\nUnfortunately, your original traceback can not be constructed.\n')
return None**
But the next operation with return value that it is called len() in IPython.core.ultratb.find_recursion, and this causes an exception and IPython crash.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 21 (12 by maintainers)
Hi. I think the issue is still existing. On my side I manage to reproduce the issue with click library. The minimal code snippet is below.
Then executed in IPython with the following argugments:
I encounter the issue with IPython version 7.22.0 , on Databricks platform using a “Python” job (actions with them are also ongoing).
Should we create a different issue for this one in case this is specific to click? Let me know. Thanks.
It seems that click is calling a
sys.exit(0)after your app has finished and ipython mistakes this as an error. We solved the problem by wrapping our application in a try except block:see also this Stackoverflow post: https://stackoverflow.com/questions/52740295/how-to-not-exit-a-click-cli
Same issue here with IPython version 7.27.0 on Databricks, are there any news on that?
Hello! I have been running into the same error, and tried to reproduce it with a minimal example. I only managed to get it the same error via a jupyter notebook, here is some info if it can help:
Setup
python: 3.9.18 Ubuntu 22.04 jammy
Code
In a notebook:
The custom handler does not do much and simply prints the exception’s traceback, using
exception_only=TrueLogs
In short, this raises:
Click to see complete logs
Side notes
tmp.pyfile and callingipython tmp.pybut for some reasons it wouldn’t call the custom exception handler.raise FooExc("outer exception")withoutfrom Exception("outer exception"), the code behave as expected i.e. logging the error.