Repository: ipython/ipython

Issue:
ipython 8.0.0 requires relatively recent pygments
After reading [the update post](https://blog.jupyter.org/release-of-ipython-8-0-6e034ff122ef), I updated my ipython to 8.0.0 using `python -m pip install ipython ipykernel --upgrade` and then tried to follow the code in the post.

```python
%xmode verbose
def foo(i):
    x = [[[0]]]
    return x[0][i][0]
def bar():
    return foo(0) + foo(1) + foo(2)
bar()
```

This crashed my ipython. I've put the full traceback at the bottom of this issue. But the real source of the problem seems to be that I had pygments 2.3.1. Upgrading to pygments 2.11.2 solved the problem (and made the ipython example work beautifully).

I wonder if it would be a good idea to add a lower bound on the version of pygments in `extras_require`?

```
Traceback (most recent call last):
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3251, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-3-226d01f48125>", line 1, in <module>
    bar()
  File "<ipython-input-2-83feff91fbf6>", line 2, in bar
    return foo(0) + foo(1) + foo(2)
  File "<ipython-input-1-9c0c42d045a3>", line 3, in foo
    return x[0][i][0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 1934, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'IndexError' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3191, in run_ast_nodes
    if await self.run_code(code, result, async_=asy):
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3268, in run_code
    self.showtraceback(running_compiled_code=True)
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 1936, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/davidlowryduda/.local/lib/python3.9/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/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 786, in format_exception_as_a_whole
    records = self.get_records(etb, number_of_lines_of_context, tb_offset)
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 830, in get_records
    style = stack_data.style_with_executing_node(style, "bg:ansiyellow")
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/stack_data/core.py", line 403, in style_with_executing_node
    class NewStyle(style):
  File "/usr/lib/python3/dist-packages/pygments/style.py", line 91, in __new__
    ndef[4] = colorformat(styledef[3:])
  File "/usr/lib/python3/dist-packages/pygments/style.py", line 58, in colorformat
    assert False, "wrong color format %r" % text
AssertionError: wrong color format 'ansiyellow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 1934, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'AssertionError' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 2814, in _run_cell
    return runner(coro)
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/async_helpers.py", line 129, in _pseudo_sync_runner
    coro.send(None)
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3012, in run_cell_async
    has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3210, in run_ast_nodes
    self.showtraceback()
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 1936, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/davidlowryduda/.local/lib/python3.9/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/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 786, in format_exception_as_a_whole
    records = self.get_records(etb, number_of_lines_of_context, tb_offset)
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 830, in get_records
    style = stack_data.style_with_executing_node(style, "bg:ansiyellow")
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/stack_data/core.py", line 403, in style_with_executing_node
    class NewStyle(style):
  File "/usr/lib/python3/dist-packages/pygments/style.py", line 91, in __new__
    ndef[4] = colorformat(styledef[3:])
  File "/usr/lib/python3/dist-packages/pygments/style.py", line 58, in colorformat
    assert False, "wrong color format %r" % text
AssertionError: wrong color format 'ansiyellow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 1934, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'AssertionError' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/__main__.py", line 14, in <module>
    start_ipython()
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/__init__.py", line 119, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/traitlets/config/application.py", line 846, in launch_instance
    app.start()
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/terminal/ipapp.py", line 316, in start
    self.shell.mainloop()
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/terminal/interactiveshell.py", line 611, in mainloop
    self.interact()
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/terminal/interactiveshell.py", line 604, in interact
    self.run_cell(code, store_history=True)
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 2768, in run_cell
    result = self._run_cell(
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 2819, in _run_cell
    self.showtraceback(running_compiled_code=True)
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 1936, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/davidlowryduda/.local/lib/python3.9/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/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 786, in format_exception_as_a_whole
    records = self.get_records(etb, number_of_lines_of_context, tb_offset)
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/IPython/core/ultratb.py", line 830, in get_records
    style = stack_data.style_with_executing_node(style, "bg:ansiyellow")
  File "/home/davidlowryduda/.local/lib/python3.9/site-packages/stack_data/core.py", line 403, in style_with_executing_node
    class NewStyle(style):
  File "/usr/lib/python3/dist-packages/pygments/style.py", line 91, in __new__
    ndef[4] = colorformat(styledef[3:])
  File "/usr/lib/python3/dist-packages/pygments/style.py", line 58, in colorformat
    assert False, "wrong color format %r" % text
AssertionError: wrong color format 'ansiyellow'

If you suspect this is an IPython 8.0.0 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

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=True
```


Discussion:
Thanks for suggesting to upgrade pygments! I kept encountering this crash in an interactive session (annoying because I was losing REPL state) and `pip3 install -U pygments` did the trick

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -152,7 +152,7 @@
         "pytest",
         "pytest-asyncio",
         "testpath",
-        "pygments",
+        "pygments>=2.4.0",
     ],
     test_extra=[
         "pytest",
@@ -162,7 +162,7 @@
         "nbformat",
         "numpy>=1.19",
         "pandas",
-        "pygments",
+        "pygments>=2.4.0",
         "trio",
     ],
     terminal=[],


Test patch: