Skip to content

16054 void swig ptr

David Gobbi requested to merge dgobbi/vtk:16054-void-swig-ptr into master

BUG 16054: Reduce chance of mistaken swig pointer string.

In the Python wrappers, the vtkDataArray::SetVoidArray() method can take two kinds of arguments:

  1. a string formatted as a swig pointer "_addr_type" where "addr" is the hexadecimal address and "type" is the type, e.g. "p_void".

  2. a Python buffer object (any Python object with buffer protocol)

A Python string (in Python 2) is also a buffer object, therefore there is some ambiguity. The use of swig pointers with VTK is exceedingly rare, so this fix requires that the string exactly matches the format "_addr_p_void" to be interpreted as a swig pointer.

Note that in Python 3, the ambiguity disappears because a string in Py3K does not have the buffer protocol. However, I believe that this use of swig pointers should be deprecated.

Merge request reports