diff --git a/qtconsole/mainwindow.py b/qtconsole/mainwindow.py index 2a53b131..4d5c86b6 100644 --- a/qtconsole/mainwindow.py +++ b/qtconsole/mainwindow.py @@ -813,9 +813,11 @@ def set_syntax_style(self, syntax_style): self.active_frontend._execute( f""" from IPython.core.ultratb import VerboseTB -try: +if getattr(VerboseTB, 'tb_highlight_style', None) is not None: + VerboseTB.tb_highlight_style = '{syntax_style}' +elif getattr(VerboseTB, '_tb_highlight_style', None) is not None: VerboseTB._tb_highlight_style = '{syntax_style}' -except AttributeError: +else: get_ipython().run_line_magic('colors', '{colors}') """, True)