-
Notifications
You must be signed in to change notification settings - Fork 182
Closed
Labels
needs reproIssue has not been reproduced yetIssue has not been reproduced yet
Description
Type: Bug
Behaviour
I am getting MatplotlibDeprecationWarning that causes an error with test_warn failed when I run this test with the PythonDebugger in the Testing extension.
versions:
pytest==8.3.1
matplotlib==3.9.2
Steps to reproduce:
import warnings
import pytest
def f():
warnings.warn("Test", UserWarning)
def test_warn():
with pytest.warns(UserWarning, match="Test"):
f()Setting a breakpoint in the line of with pytest.warns(UserWarning, match="Test"): and run in debug-mode. The debugger raises an error:
Diagnostic data
Traceback:
/home/stefanie/code/scikit-learn_dev/scikit-learn/sklearn/test_warn.py::test_warn failed: def test_warn():
> with pytest.warns(UserWarning, match="Test"):
sklearn/test_warn.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<stringsource>:69: in cfunc.to_py.__Pyx_CFunc_b0409f__29_pydevd_sys_monitoring_cython_object__lParen__etc_to_py_4code_4line.wrap
???
_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx:1429: in _pydevd_sys_monitoring_cython._line_event
???
_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx:1471: in _pydevd_sys_monitoring_cython._internal_line_event
???
_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx:1278: in _pydevd_sys_monitoring_cython._stop_on_breakpoint
???
_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx:1906: in _pydevd_sys_monitoring_cython._do_wait_suspend
???
../../../.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py:2197: in do_wait_suspend
keep_suspended = self._do_wait_suspend(thread, frame, event, arg, trace_suspend_type, from_this_thread, frames_tracker)
../../../.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py:2223: in _do_wait_suspend
self._activate_gui_if_needed()
../../../.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py:1685: in _activate_gui_if_needed
activate_function()
../../../.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py:1668: in <lambda>
"matplotlib": lambda: activate_matplotlib(do_enable_gui),
../../../.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py:99: in activate_matplotlib
is_interactive = is_interactive_backend(backend)
../../../.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py:59: in is_interactive_backend
from matplotlib.rcsetup import interactive_bk, non_interactive_bk # @UnresolvedImport
../../../.pyenv/versions/3.12.2/envs/scikit-learn_dev/lib/python3.12/site-packages/matplotlib/_api/__init__.py:216: in __getattr__
return props[name].__get__(instance)
../../../.pyenv/versions/3.12.2/envs/scikit-learn_dev/lib/python3.12/site-packages/matplotlib/_api/deprecation.py:161: in __get__
emit_warning()
../../../.pyenv/versions/3.12.2/envs/scikit-learn_dev/lib/python3.12/site-packages/matplotlib/_api/deprecation.py:196: in emit_warning
warn_deprecated(
../../../.pyenv/versions/3.12.2/envs/scikit-learn_dev/lib/python3.12/site-packages/matplotlib/_api/deprecation.py:99: in warn_deprecated
warn_external(warning, category=MatplotlibDeprecationWarning)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
message = MatplotlibDeprecationWarning('The interactive_bk attribute was deprecated in Matplotlib 3.9 and will be removed in 3.11. Use ``matplotlib.backends.backend_registry.list_builtin(matplotlib.backends.BackendFilter.INTERACTIVE)`` instead.')
category = <class 'matplotlib._api.deprecation.MatplotlibDeprecationWarning'>
def warn_external(message, category=None):
"""
`warnings.warn` wrapper that sets *stacklevel* to "outside Matplotlib".
The original emitter of the warning can be obtained by patching this
function back to `warnings.warn`, i.e. ``_api.warn_external =
warnings.warn`` (or ``functools.partial(warnings.warn, stacklevel=2)``,
etc.).
"""
frame = sys._getframe()
for stacklevel in itertools.count(1):
if frame is None:
# when called in embedded context may hit frame is None
break
if not re.match(r"\A(matplotlib|mpl_toolkits)(\Z|\.(?!tests\.))",
# Work around sphinx-gallery not setting __name__.
frame.f_globals.get("__name__", "")):
break
frame = frame.f_back
# preemptively break reference cycle between locals and the frame
del frame
> warnings.warn(message, category, stacklevel)
E matplotlib._api.deprecation.MatplotlibDeprecationWarning: The interactive_bk attribute was deprecated in Matplotlib 3.9 and will be removed in 3.11. Use ``matplotlib.backends.backend_registry.list_builtin(matplotlib.backends.BackendFilter.INTERACTIVE)`` instead.
../../../.pyenv/versions/3.12.2/envs/scikit-learn_dev/lib/python3.12/site-packages/matplotlib/_api/__init__.py:381: MatplotlibDeprecationWarning
I would have expected not to see this warning and be able to continue with the debugging.
Running the test with Testing without debug points or running the tests with pytest on the terminal works just fine.
Extension version: 2024.12.0
VS Code version: Code 1.95.2 (e8653663e8840adaf45af01eab5c627a5af81807, 2024-11-07T11:07:22.054Z)
OS version: Linux x64 6.11.5-arch1-1
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.12.2
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): VirtualEnvironment
Details
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) Ultra 5 125U (14 x 4300) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off webnn: disabled_off |
| Load (avg) | 0, 0, 0 |
| Memory (System) | 15.31GB (6.93GB free) |
| Process Argv | . --crash-reporter-id f2feb425-5c1a-45d2-b717-9a771200dd5b |
| Screen Reader | no |
| VM | 0% |
| DESKTOP_SESSION | gnome |
| XDG_CURRENT_DESKTOP | GNOME |
| XDG_SESSION_DESKTOP | gnome |
| XDG_SESSION_TYPE | wayland |
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythongtdpath:30769146
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
945dj816:31013170
dvdeprecation:31068756
dwnewjupyter:31046869
newcmakeconfigv2:31071590
impr_priority:31102340
nativerepl2:31139839
refactort:31108082
pythonrstrctxt:31112756
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
Metadata
Metadata
Assignees
Labels
needs reproIssue has not been reproduced yetIssue has not been reproduced yet