View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015647VTK(No Category)public2015-08-13 14:352016-02-12 11:34
ReporterRafael Bertoldi 
Assigned ToDavid Gobbi 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version6.2.0 
Target VersionFixed in Version7.1.0 
Summary0015647: Incorrect generation of Python code for a C++ method with >1 PyObject* argument
DescriptionHello, people

We were developing a new feature in our company that required us to bind a VTK actor developed in C++ to our Python code. One of the methods in our VTK actor is similar to one below:

```
void SetSomething(
  PyObject *a1,
  PyObject *a2,
  PyObject *a3,
  PyObject *a4
);
```

However the generated Python binding code ended up incorrect. The generated code for function in question looked like this:

```
static PyObject *
PyvtkMyActor_SetSomething(PyObject *self, PyObject *args)
{
  vtkPythonArgs ap(self, args, "SetSomething");
  vtkObjectBase *vp = ap.GetSelfPointer(self, args);
  vtkMyActor *op = static_cast<vtkMyActor *>(vp);

  PyObject *temp0 = NULL;
  PyObject *result = NULL;

  if (op && ap.CheckArgCount(4) &&
      ap.GetPythonObject(temp0) &&
      ap.GetPythonObject(temp1) &&
      ap.GetPythonObject(temp2) &&
      ap.GetPythonObject(temp3))
    {
    if (ap.IsBound())
      {
      op->SetSomething(temp0, temp1, temp2, temp3);
      }
    else
      {
      op->vtkMyActor::SetSomething(temp0, temp1, temp2, temp3);
      }

    if (!ap.ErrorOccurred())
      {
      result = ap.BuildNone();
      }
    }

  return result;
}
```

Notice the missing declaration of variables temp1, temp2 and temp3, which correspond to 2nd through 4th arguments. Curiously the rest of method counts and notices the number of arguments correctly.

We looked around VTK source code and the problem seems to be the break statement in line 92 of vtkWrapPython_DeclareVariables method of vtkWrapPythonMethod.c file. It looks like it should be a continue, as it should not prevent further arguments from being declared just because a PyObject argument was found.

If you need further information to reproduce, let me know.
 
TagsNo tags attached.
ProjectTBD
Typeincorrect functionality
Attached Files

 Relationships

  Notes
(0035726)
David Gobbi (developer)
2016-02-11 23:28

https://gitlab.kitware.com/vtk/vtk/merge_requests/1213 [^]
(0035729)
David Gobbi (developer)
2016-02-12 11:34

https://gitlab.kitware.com/vtk/vtk/commit/eacf1d20 [^]

 Issue History
Date Modified Username Field Change
2015-08-13 14:35 Rafael Bertoldi New Issue
2016-02-11 23:28 David Gobbi Note Added: 0035726
2016-02-11 23:28 David Gobbi Assigned To => David Gobbi
2016-02-11 23:28 David Gobbi Status backlog => gerrit review
2016-02-12 11:34 David Gobbi Note Added: 0035729
2016-02-12 11:34 David Gobbi Status gerrit review => closed
2016-02-12 11:34 David Gobbi Resolution open => fixed
2016-02-12 11:34 David Gobbi Fixed in Version => 7.1.0


Copyright © 2000 - 2018 MantisBT Team