[vtk-developers] vtkInteratorStyle python subclass instantiation: TypeError: method requires a string argument

David Lonie david.lonie at kitware.com
Thu Aug 27 09:56:24 EDT 2015


On Wed, Aug 26, 2015 at 3:02 PM, David Lonie <david.lonie at kitware.com>
wrote:

> I'm updating some code for a client to use current VTK master, and there's
> an error while instantiating a python class that derives from
> vtkInteractorStyle. It seems to be related to __init__ taking an extra
> parameter which is used by the subclass to initialize some internals.
>
> A minimal example that reproduces the error:
>
> test.py:
> import vtk
>
> class MyInteractorStyle(vtk.vtkInteractorStyleUser):
>   def __init__(self, arg):
>     pass
>
> obj = MyInteractorStyle(2)
>
> $ vtkpython test.py
> Traceback (most recent call last):
>   File "/tmp/test.py", line 7, in <module>
>     obj = MyInteractorStyle(2)
> TypeError: method requires a string argument
>
> Removing the extra argument from __init__ will make the error go away.
>
> This worked a few months ago last time we bumped their VTK version. Is
> this a bug?
>

It looks like the issue is in PyVTKObject_New, which treats all __init__
arguments as SWIG pointers for object initialization. I'm not familiar with
the usecase for that, is there some additional check we can perform to pass
over regular arguments?

Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20150827/1ab9654b/attachment.html>


More information about the vtk-developers mailing list