Skip to content

Add method preconditions for Python wrappers

David Gobbi requested to merge dgobbi/vtk:expects into master

The new VTK_EXPECTS() macro is used to add preconditions to method calls from the Python wrappers. For example, a method can be declared as follows:

void SetPoint(vtkIdType id, const double x[3])
  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());

The Python wrappers will raise a ValueError exception when the method is called with a bad index, instead of passing the bad index to C++ where it could potentially cause a crash.

Merge request reports