[NumPy-Tickets] [NumPy] #1110: Error packing Numpy scalars with struct.pack

NumPy Trac numpy-tickets@scipy....
Wed Feb 3 08:41:19 CST 2010

#1110: Error packing Numpy scalars with struct.pack
 Reporter:  bryancatanzaro  |       Owner:  somebody
     Type:  defect          |      Status:  new     
 Priority:  normal          |   Milestone:          
Component:  numpy.core      |     Version:  1.4.0rc1
 Keywords:                  |  

Comment(by caleb):

 A similar problem occurs with 1.4.0 (and 1.3.0) on Python 2.6.2
 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32.
 (I'm not using PyCUDA.)

 Reproduce from the command line:

 >>> import numpy
 >>> import struct
 >>> a = numpy.array([1,2,3], "uint16")
 >>> struct.pack("<3H", *a)
 sys:1: DeprecationWarning: struct integer overflow masking is deprecated
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 SystemError: ..\Objects\longobject.c:336: bad argument to internal

 The same will occur with unit32 and "<3I".

 Note the following works:

 >>> struct.pack("3H", *a)
 >>> struct.pack("<3H", *(a.tolist()))
 >>> a = numpy.array([1,2,3], "int16")
 >>> struct.pack("<3h", *a)

 and so does int32.

Ticket URL: <http://projects.scipy.org/numpy/ticket/1110#comment:8>
NumPy <http://projects.scipy.org/numpy>
My example project

More information about the NumPy-Tickets mailing list