Invalid exec call crashed IPython shell
Author: doerwalterCreated Sep 11, 2020Updated Aug 16, 2026
Labelsbug
The following code snippet, when typed into an IPython shell, crashes IPython:
exec('a = 5', {}, [])(What should have been the locals dictionary is a list instead).
The complete terminal looks like this:
$ ipython --quick
Python 3.8.5 (default, Jul 21 2020, 10:48:26)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.18.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: exec('a = 5', {}, [])
Traceback (most recent call last):
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3417, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-c9e39d947ace>", line 1, in <module>
exec('a = 5', {}, [])
File "<string>", line 1, in <module>
TypeError: list indices must be integers or slices, not str
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 2044, in showtraceback
stb = value._render_traceback_()
AttributeError: 'TypeError' object has no attribute '_render_traceback_'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3337, in run_ast_nodes
if (await self.run_code(code, result, async_=asy)):
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3434, in run_code
self.showtraceback(running_compiled_code=True)
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 2046, in showtraceback
stb = self.InteractiveTB.structured_traceback(etype,
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1435, in structured_traceback
return FormattedTB.structured_traceback(
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1335, in structured_traceback
return VerboseTB.structured_traceback(
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1192, in structured_traceback
formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1152, in format_exception_as_a_whole
frames = self.format_records(records, last_unique, recursion_repeat)
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 891, in format_records
if r[0].f_locals.get("__tracebackhide__", 0):
AttributeError: 'list' object has no attribute 'get'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 2044, 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 "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 2922, in _run_cell
return runner(coro)
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/async_helpers.py", line 68, in _pseudo_sync_runner
coro.send(None)
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3145, in run_cell_async
has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3356, in run_ast_nodes
self.showtraceback()
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 2046, in showtraceback
stb = self.InteractiveTB.structured_traceback(etype,
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1435, in structured_traceback
return FormattedTB.structured_traceback(
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1335, in structured_traceback
return VerboseTB.structured_traceback(
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1210, in structured_traceback
formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context,
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1152, in format_exception_as_a_whole
frames = self.format_records(records, last_unique, recursion_repeat)
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 891, in format_records
if r[0].f_locals.get("__tracebackhide__", 0):
AttributeError: 'list' object has no attribute 'get'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 2044, 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 "/Users/walter/pyvenvs/ipython-bad/bin/ipython", line 8, in <module>
sys.exit(start_ipython())
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/__init__.py", line 126, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/traitlets/config/application.py", line 837, in launch_instance
app.start()
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 356, in start
self.shell.mainloop()
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 564, in mainloop
self.interact()
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 555, in interact
self.run_cell(code, store_history=True)
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 2876, in run_cell
result = self._run_cell(
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 2927, in _run_cell
self.showtraceback(running_compiled_code=True)
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 2046, in showtraceback
stb = self.InteractiveTB.structured_traceback(etype,
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1435, in structured_traceback
return FormattedTB.structured_traceback(
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1335, in structured_traceback
return VerboseTB.structured_traceback(
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1210, in structured_traceback
formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context,
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 1152, in format_exception_as_a_whole
frames = self.format_records(records, last_unique, recursion_repeat)
File "/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython/core/ultratb.py", line 891, in format_records
if r[0].f_locals.get("__tracebackhide__", 0):
AttributeError: 'list' object has no attribute 'get'
If you suspect this is an IPython 7.18.1 bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at [email protected]
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=Truepython -c "import IPython; print(IPython.sys_info())" reports the following:
{'commit_hash': '95d2b79a2',
'commit_source': 'installation',
'default_encoding': 'utf-8',
'ipython_path': '/Users/walter/pyvenvs/ipython-bad/lib/python3.8/site-packages/IPython',
'ipython_version': '7.18.1',
'os_name': 'posix',
'platform': 'macOS-10.15.6-x86_64-i386-64bit',
'sys_executable': '/Users/walter/pyvenvs/ipython-bad/bin/python',
'sys_platform': 'darwin',
'sys_version': '3.8.5 (default, Jul 21 2020, 10:48:26) \n'
'[Clang 11.0.3 (clang-1103.0.32.62)]'}Source: ipython/ipython