Skip to content

ipython_view: Handle background color in ANSI escape codes rather than running into exception

As described in more detail in the commit messages, this fixes the issue of unhandled ANSI escape codes I get on Debian testing with ipython3 8.5.0-4, as e.g. in this example:

In [1]: ''.nonExistingMethod()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [1], line 1
----> 1
Traceback (most recent call last):
  File "/home/michi/temp/accerciser/share/accerciser/plugins/ipython_view.py", line 522, in _showReturned
    self._write('\n'+text)
  File "/home/michi/temp/accerciser/share/accerciser/plugins/ipython_view.py", line 454, in _write
    self.text_buffer.insert_with_tags_by_name(self.text_buffer.get_end_iter(),
  File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 784, in insert_with_tags_by_name
    raise ValueError('unknown text tag: %s' % tag)
ValueError: unknown text tag: 38;5;124;43
  Cell In [2], line 2
    ---------------------------------------------------------------------------
                                                                               ^
SyntaxError: invalid syntax

(More real-world example is e.g. calling a pyatspi method on an accessible object with too few arguments.)

Merge request reports