Skip to content

Raise DeprecationWarning in Python for deprecated methods

David Gobbi requested to merge dgobbi/vtk:python-warn-deprecation into master

In order to get the deprecation warnings from Python instead of from the VTK_LEGACY_BODY macros in the C++ code, you must configure VTK with VTK_LEGACY_SILENT=ON and call the following from Python:

import warnings
warnings.filterwarnings("default", category=DeprecationWarning)

When building wheels, VTK_LEGACY_SILENT=ON is now set automatically. The warning text is formatted as follows:

DeprecationWarning: Call to deprecated method SetUseStdErrorForAllMessages. (Use
vtkOutputWindow::SetDisplayMode) -- Deprecated since version 9.0.0.

A DeprecationWarning is emitted when:

  1. A deprecated method is called.
  2. A static method of a deprecated class is called.
  3. A constructor of a deprecated class is called.

Closes: #18148 (closed)

Edited by David Gobbi

Merge request reports

Loading