[vtk-developers] Warnings with python 2.6, python guru wanted

Francois Bertel francois.bertel at kitware.com
Sat Apr 25 13:01:40 EDT 2009


Hello,

The first 6 warnings in VTK/Common/vtkPythonUtil.cxx on arkadia are
due to the use of Python 2.6 in Ubuntu 9.04:

http://www.cdash.org/CDash/viewBuildError.php?type=1&buildid=319881

I identified 2 issues:


* ISSUE1:

file /usr/include/python2.6/object.h contains:

typedef struct {
        readbufferproc bf_getreadbuffer;
        writebufferproc bf_getwritebuffer;
        segcountproc bf_getsegcount;
        charbufferproc bf_getcharbuffer;
        getbufferproc bf_getbuffer;
        releasebufferproc bf_releasebuffer;
} PyBufferProcs;

the last two fields (bf_getbuffer and bf_releasebuffer) seem new:
http://www.python.org/dev/peps/pep-3118/

Is there any python guru who can tell if the following lines in
VTK/Common/vtkPythonUtil.cxx:

static PyBufferProcs array_as_buffer = {
#if PY_VERSION_HEX >= 0x02050000
  (readbufferproc)array_getreadbuf,    /*bf_getreadbuffer*/
  (writebufferproc)array_getwritebuf,  /*bf_getwritebuffer*/
  (segcountproc)array_getsegcount,            /*bf_getsegcount*/
  (charbufferproc)array_getcharbuf,    /*bf_getcharbuffer*/
#else
  (getreadbufferproc)array_getreadbuf,    /*bf_getreadbuffer*/
  (getwritebufferproc)array_getwritebuf,  /*bf_getwritebuffer*/
  (getsegcountproc)array_getsegcount,         /*bf_getsegcount*/
  (getcharbufferproc)array_getcharbuf,    /*bf_getcharbuffer*/
#endif
};

could be just safely changed to:

static PyBufferProcs array_as_buffer = {
#if PY_VERSION_HEX >= 0x02050000
  (readbufferproc)array_getreadbuf,    /*bf_getreadbuffer*/
  (writebufferproc)array_getwritebuf,  /*bf_getwritebuffer*/
  (segcountproc)array_getsegcount,            /*bf_getsegcount*/
  (charbufferproc)array_getcharbuf,    /*bf_getcharbuffer*/
 #if PY_VERSION_HEX >= 0x02060000
    (getbufferproc)0, /* bf_getbuffer */
    (releasebufferproc)0 /* bf_releasebuffer */
 #endif
#else
  (getreadbufferproc)array_getreadbuf,    /*bf_getreadbuffer*/
  (getwritebufferproc)array_getwritebuf,  /*bf_getwritebuffer*/
  (getsegcountproc)array_getsegcount,         /*bf_getsegcount*/
  (getcharbufferproc)array_getcharbuf,    /*bf_getcharbuffer*/
#endif
};



ISSUE2:

the same /usr/include/python2.6/object.h also contains:

typedef struct _typeobject {
[...]
       /* Type attribute cache version tag. Added in version 2.6 */
        unsigned int tp_version_tag;
[...]
} PyTypeObject;


How should PyVTKObjectType in VTK/Common/vtkPythonUtil.cxx be safely
changed to avoid the warning?


-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtk-developers mailing list