[Numpy-discussion] User data types

Martin Teichmann martin.teichmann@mbi-berlin...
Sat Oct 24 06:38:29 CDT 2009

Hello List,

I'm working on an extension for pytables,
a package to store numpy arrays into hdf5 files.

hdf5 supports the additional datatype "reference",
which makes sense only in an hdf5 context. In order
to be able to use them in pytables, I figured the
best idea is to define a user-defined datatype,
register it with PyArray_RegisterDataType and insert
it into the typeDict. This all works fine, except that
spurious exceptions are risen after one has
called dtype("r") (I use r as the type code).

I tracked it down to the function PyArray_DescrConverter,
which calls PyArray_DescrFromType (just after the finish:
label). This function sets a python exception with
PyErr_SetString and returns NULL. But the calling
function ignores this, and returns successfully. The
exception then is still dangling, and at a later time
will be risen in completely unrelated code.

I guess a PyErr_Clear should be added at the
beginning of the if-clause to solve the problem.

I submitted this bug as Ticket #1255 to the numpy
trac system, where you can also find the code
that triggered the bug.


Martin Teichmann

More information about the NumPy-Discussion mailing list