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
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to