File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -520,7 +520,11 @@ def draw_if_interactive() -> None:
520
520
matplotlib .backends .backend = newbackend # type: ignore[attr-defined]
521
521
522
522
# Make sure the repl display hook is installed in case we become interactive.
523
- install_repl_displayhook ()
523
+ try :
524
+ install_repl_displayhook ()
525
+ except NotImplementedError as err :
526
+ _log .warning ("Fallback to a different backend" )
527
+ raise ImportError from err
524
528
525
529
526
530
def _warn_if_gui_out_of_main_thread () -> None :
Original file line number Diff line number Diff line change @@ -629,6 +629,21 @@ def test_blitting_events(env):
629
629
assert 0 < ndraws < 5
630
630
631
631
632
+ def _fallback_check ():
633
+ import IPython .core .interactiveshell as ipsh
634
+ import matplotlib .pyplot
635
+ ipsh .InteractiveShell .instance ()
636
+ matplotlib .pyplot .figure ()
637
+
638
+
639
+ def test_fallback_to_different_backend ():
640
+ pytest .importorskip ("IPython" )
641
+ # Runs the process that caused the GH issue 23770
642
+ # making sure that this doesn't crash
643
+ # since we're supposed to be switching to a different backend instead.
644
+ response = _run_helper (_fallback_check , timeout = _test_timeout )
645
+
646
+
632
647
def _impl_test_interactive_timers ():
633
648
# A timer with <1 millisecond gets converted to int and therefore 0
634
649
# milliseconds, which the mac framework interprets as singleshot.
You can’t perform that action at this time.
0 commit comments