Skip to content

Commit cc85ca8

Browse files
authored
Handle new matplotlib versions (#1791)
Fixes: #1623
1 parent 24aa6a5 commit cc85ca8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,30 @@ def find_gui_and_backend():
5353
return gui, backend
5454

5555

56+
def _get_major_version(module):
57+
return int(module.__version__.split('.')[0])
58+
59+
60+
def _get_minor_version(module):
61+
return int(module.__version__.split('.')[1])
62+
63+
5664
def is_interactive_backend(backend):
5765
"""Check if backend is interactive"""
5866
matplotlib = sys.modules["matplotlib"]
59-
from matplotlib.rcsetup import interactive_bk, non_interactive_bk # @UnresolvedImport
67+
new_api_version = (3, 9)
68+
installed_version = (
69+
_get_major_version(matplotlib),
70+
_get_minor_version(matplotlib)
71+
)
72+
73+
if installed_version >= new_api_version:
74+
interactive_bk = matplotlib.backends.backend_registry.list_builtin(
75+
matplotlib.backends.BackendFilter.INTERACTIVE)
76+
non_interactive_bk = matplotlib.backends.backend_registry.list_builtin(
77+
matplotlib.backends.BackendFilter.NON_INTERACTIVE)
78+
else:
79+
from matplotlib.rcsetup import interactive_bk, non_interactive_bk # @UnresolvedImport
6080

6181
if backend in interactive_bk:
6282
return True

0 commit comments

Comments
 (0)