question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IPython crash when use showtraceback with exception_only=True

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
swan001commented, Nov 29, 2021

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.

import click

@click.command()
@click.option('--nb_files', type=int, help='number of files to load')
def execute_job(nb_files):
    print('hello world', nb_files)
    return nb_files

if __name__ == '__main__':
    execute_job()

Then executed in IPython with the following argugments:

--nb_files 20

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.

1reaction
AlexF1994commented, Mar 10, 2022

Same issue here with IPython version 7.27.0 on Databricks, are there any news on that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Crash while rendering traceback · Issue #12467 · ipython ...
Running code that uses raise from inside Jupyter interfaces or IPython will trigger the bug. The behaviour is the following: JupyterLab or ...
Read more >
Ipython: Autocompletion crashes session ('sys' is not defined)
When I try to use iPython's auto-completion, the session crashes with the following error: Traceback (most recent call last): File ...
Read more >
Issues closed in the 0.12 development cycle — IPython 8.6.0 ...
643: enable gui eventloop integration in ipkernel. 965: ipython is crashed without launch.(python3.2). 958: Can't use os X clipboard on with qtconsole.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found