[vtkusers] python reader.GetFileName() seg faults

Randy Heiland heiland at ncsa.uiuc.edu
Thu Jul 27 13:11:43 EDT 2000


On Jul 27, 12:42pm, Chris Myers wrote:
> Subject: Re: [vtkusers] python reader.GetFileName() seg faults
> Randy,
>
> Re: Python seg faulting with reader.GetFileName()...
>
> >From the trace below, you can see that Python is seg faulting in
> PyString_FromString().  Poking around comp.lang.python, I find that,
> at least as of a few months ago (i.e., in version 1.5.2),
> PyString_FromString applied to a NULL char* pointer will seg fault
> rather than return Py_None, i.e., that one must explicitly check that
> the pointer is not NULL before calling the string conversion function.
>
> I am running Python 1.5.2; you are running 1.6a2.  Perhaps Python
> has changed the behavior of PyString_FromString in 1.6a2, but I haven't
> yet found any explicit mention of that in the 1.6 Change Logs.
>
> I am running a reasonably recent nightly release of VTK (a few weeks
> old), so I doubt that the Python wrapper generation is significantly
> different between your version and mine.  Looking at
> python/vtkUnstructuredGridReaderPython.cxx, I find the following
> fragment:
>
>    if (PyArg_ParseTuple(args, ""))
>    {
> 	if (!error)
>         {
>              temp20 = op->GetFileName();
>              return PyString_FromString(temp20);
>         }
>    }
>
> If you have that file still lying around, you might want to check
> whether the pointer is being checked before the function call,
> but I suspect the difference is in the upgrade to Python.

It's not -- very same code as yours.

>
> At the very least, the VTK wrapper code generation seems insufficient
> for Python 1.5.2.
>
> Can this be easily fixed in VTK?

Actually, I just tried it using:

Python 1.5.2 (#10, Jan  4 2000, 08:17:24) [C] on irix646

and it worked too.  Not sure what 1.5.2 build you were using.  Guess I'd
recommend that you update your Python - which would mean rebuilding VTK :(
Of course, I don't thoroughly understand your predicament.  Why can't you just
set a dummy filename and check for it later?

As David Gobbi has pointed out recently, yes, there are known problems with the
Python wrappers - which you haven't stumbled upon yet.

--Randy




More information about the vtkusers mailing list