Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ipython 8+ python crash on exception #13598

@2sn

Description

@2sn

Since version 8 in Ipython I frequently - very frequently - get IPython crashes (termination) of the kind below.

I think the specific situation is that I edit code, I use autoreload(3), there is a bug, but when IPython tries traceback it crashes and terminates. Since a main point of using IPython is the auto-reload, this makes it almost unusable for development compared to Version 7.x.x. (Certainly distracting enough to spend the time to finally post it here.)

I have seen there is a few other bugs of that kind reported, but I was not sure which would be similar enough to any of them, hence I post this separately. My apologies for any duplications.

I am not sure whether the error is strictly reproducible as it happens in situations when code is edited.

I use Python 3.10.2 built from source on Linux (Fedora 34).

I am using pylab mode which loads matplotlib, I am not sure whether their event loop may interfere with IPython.
Just a thought.

In [15]: m.plot1()
Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1979, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'NotOneValueFound' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1981, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 871, in structured_traceback
    formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 804, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 723, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 698, in lines
    pieces = self.included_pieces
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 628, in executing_piece
    return only(
  File "/home/alex/Python/lib/python3.10/site-packages/executing/executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

Original exception was:
Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3361, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-15-0de954ff7b19>", line 1, in <cell line: 1>
  File "/home/alex/python/source/multistar/base.py", line 586, in plot1
    rr = norm(self.y[self.y_rad])
AttributeError: 'Direct' object has no attribute 'y_rad'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1979, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'AttributeError' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3301, in run_ast_nodes
    if await self.run_code(code, result, async_=asy):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3378, in run_code
    self.showtraceback(running_compiled_code=True)
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1981, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 852, in structured_traceback
    formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 804, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 723, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 698, in lines
    pieces = self.included_pieces
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 628, in executing_piece
    return only(
  File "/home/alex/Python/lib/python3.10/site-packages/executing/executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1979, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'NotOneValueFound' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 2900, in _run_cell
    return runner(coro)
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/async_helpers.py", line 129, in _pseudo_sync_runner
    coro.send(None)
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3098, in run_cell_async
    has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3320, in run_ast_nodes
    self.showtraceback()
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1981, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 871, in structured_traceback
    formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 804, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 723, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 698, in lines
    pieces = self.included_pieces
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 628, in executing_piece
    return only(
  File "/home/alex/Python/lib/python3.10/site-packages/executing/executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1979, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'NotOneValueFound' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/bin/ipython3", line 8, in <module>
    sys.exit(start_ipython())
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/__init__.py", line 123, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/home/alex/Python/lib/python3.10/site-packages/traitlets/config/application.py", line 846, in launch_instance
    app.start()
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/terminal/ipapp.py", line 318, in start
    self.shell.mainloop()
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 653, in mainloop
    self.interact()
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 646, in interact
    self.run_cell(code, store_history=True)
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 2854, in run_cell
    result = self._run_cell(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 2905, in _run_cell
    self.showtraceback(running_compiled_code=True)
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1981, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 871, in structured_traceback
    formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 804, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 723, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 698, in lines
    pieces = self.included_pieces
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 628, in executing_piece
    return only(
  File "/home/alex/Python/lib/python3.10/site-packages/executing/executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions