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

David Gobbi david.gobbi at gmail.com
Thu Aug 27 10:09:52 EDT 2015


Hi David,

Yes, it seems to be a bug related to the py3k modifications.  I believe
that the swig-pointer initializer is still used in some places (it allows a
person to create a python-wrapped VTK object, if all they have is a pointer
to the object).

I'm going away for a few days but I'll take a look when I get back.

 - David


On Thu, Aug 27, 2015 at 7:56 AM, David Lonie <david.lonie at kitware.com>
wrote:

> 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/d490b817/attachment.html>


More information about the vtk-developers mailing list