[issue2263] struct.pack() + numpy int raises SystemError

Just van Rossum report at bugs.python.org
Mon Mar 10 08:39:24 CET 2008


New submission from Just van Rossum <just at letterror.com>:

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.

Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import struct
>>> import numpy
>>> i = numpy.int16(1)
>>> struct.pack(">B", i)
__main__:1: DeprecationWarning: struct integer overflow masking is 
deprecated
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/struct.
py", line 63, in pack
    return o.pack(*args)
SystemError: /Users/ronald/r252/Objects/longobject.c:322: bad argument 
to internal function
>>> struct.pack(">H", i)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/struct.
py", line 63, in pack
    return o.pack(*args)
SystemError: /Users/ronald/r252/Objects/longobject.c:322: bad argument 
to internal function
>>> struct.pack(">h", i)
'\x00\x01'
>>> struct.pack(">b", i)
'\x01'
>>> struct.pack("B", i)
'\x01'
>>> struct.pack("h", i)
'\x01\x00'
>>> numpy.__version__
'1.0.4'
>>>

----------
components: Library (Lib)
messages: 63435
nosy: jvr
severity: normal
status: open
title: struct.pack() + numpy int raises SystemError
type: behavior
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2263>
__________________________________


More information about the Python-bugs-list mailing list