[Python-Dev] [issue2263] struct.pack() + numpy int raises SystemError
grubert at users.sourceforge.net
grubert at users.sourceforge.net
Thu Feb 12 18:32:11 CET 2009
hello,
i took a look at unassigned open issue with the oldest activity
this happened to be issue2263
Original bug report:
struct.pack() raises SystemError when fed a numpy integer in some cases.
The following was run on MacOSX 10.4, little endian (I can only
reproduce the error if I specify big endian for the struct format). Not
sure if this could be a numpy bug.
i checked on ubuntu 8.04, Python 2.7a0 (trunk:69044) and numpy 1.2.1
and found
* signed always works, longlong also.
* unsigned native works half of the time
* unsigned little/big endian never works
digging into the source, for pack "B", ">B" and "<B", in _struct.c
* native packaging calls np_ubyte which calls get_long
* bigendian calls bp_uint which calls get_wrapped_ulong
get_wrapped_ulong checks the operand type by
PyInt_Check and numpy.int16, tp_flags does not contain
Py_TPFLAGS_INT_SUBCLASS
Including Py_TPFLAGS_INT_SUBCLASS in numpy's BASEFLAGS cures this.
(for positive values, packing negative numpy scalars needs a closer
look)
This seams to be an external problem then.
But I could not find any reference to Py_TPFLAGS_*_SUBCLASS in the
documentation, that is a python problem.
hope this is of any use.
cheers
engelbert
More information about the Python-Dev
mailing list