Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa92cf9

Browse files
authored
Merge pull request#25870 from turnipseason/bug-fix-for-issue-23770
Adds error handling around install_repl_displayhook
2 parents8ac84ec +321b769 commitfa92cf9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

‎lib/matplotlib/pyplot.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,11 @@ def draw_if_interactive() -> None:
520520
matplotlib.backends.backend=newbackend# type: ignore[attr-defined]
521521

522522
# Make sure the repl display hook is installed in case we become interactive.
523-
install_repl_displayhook()
523+
try:
524+
install_repl_displayhook()
525+
exceptNotImplementedErroraserr:
526+
_log.warning("Fallback to a different backend")
527+
raiseImportErrorfromerr
524528

525529

526530
def_warn_if_gui_out_of_main_thread()->None:

‎lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,21 @@ def test_blitting_events(env):
629629
assert0<ndraws<5
630630

631631

632+
def_fallback_check():
633+
importIPython.core.interactiveshellasipsh
634+
importmatplotlib.pyplot
635+
ipsh.InteractiveShell.instance()
636+
matplotlib.pyplot.figure()
637+
638+
639+
deftest_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+
632647
def_impl_test_interactive_timers():
633648
# A timer with <1 millisecond gets converted to int and therefore 0
634649
# milliseconds, which the mac framework interprets as singleshot.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp