Bugs item #522828, was opened at 2002-02-26 05:35
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=112867&aid=522828&group_id=12867
Category: Core
>Group: Fixed in next release
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Finn Bock (bckfnn)
Summary: struct.pack('>NNs', v) fails for NN > 20
Initial Comment:
When using struct.pack with Jython 2.1, an attempt to
pack a string longer than 20 characters will cause a
Java array overflow. See below for example.
% jython
Jython 2.1 on java1.2 (JIT: sunwjit)
Type "copyright", "credits" or "license" for more
information.
>>> a = 'abcd'
>>> b = 8*a
>>> len(b)
32
>>> b
'abcdabcdabcdabcdabcdabcdabcdabcd'
>>> import struct
>>> struct.pack('>32s', b)
Traceback (innermost last):
File "<console>", line 1, in ?
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.python.modules.struct$ByteStream.write(Compiled
Code)
at
org.python.modules.struct$ByteStream.writeString(Compiled
Code)
at
org.python.modules.struct$StringFormatDef.doPack(Compiled
Code)
at org.python.modules.struct.pack(Compiled Code)
at java.lang.reflect.Method.invoke(Native Method)
at
org.python.core.PyReflectedFunction.__call__(Compiled
Code)
at
org.python.core.PyReflectedFunction.__call__(Compiled
Code)
at org.python.core.PyObject.__call__(Compiled Code)
at org.python.core.PyObject.invoke(Compiled Code)
at org.python.pycode._pyx9.f$0(Compiled Code)
at org.python.pycode._pyx9.call_function(Compiled
Code)
at org.python.core.PyTableCode.call(Compiled Code)
at org.python.core.PyCode.call(Compiled Code)
at org.python.core.Py.runCode(Compiled Code)
at org.python.core.Py.exec(Compiled Code)
at org.python.util.PythonInterpreter.exec(Compiled
Code)
at
org.python.util.InteractiveInterpreter.runcode(Compiled
Code)
at
org.python.util.InteractiveInterpreter.runsource(Compiled
Code)
at
org.python.util.InteractiveInterpreter.runsource(Compiled
Code)
at org.python.util.InteractiveConsole.push(Compiled
Code)
at
org.python.util.InteractiveConsole.interact(Compiled
Code)
at org.python.util.jython.main(Compiled Code)
java.lang.ArrayIndexOutOfBoundsException:
java.lang.ArrayIndexOutOfBoundsException
>>>
----------------------------------------------------------------------
>Comment By: Finn Bock (bckfnn)
Date: 2002-03-11 13:40
Message:
Logged In: YES
user_id=4201
Fixed in struct.java: 2.6;
----------------------------------------------------------------------
Comment By: Finn Bock (bckfnn)
Date: 2002-03-11 13:37
Message:
Logged In: YES
user_id=4201
Added as test356
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2002-02-27 02:05
Message:
Logged In: NO
This doesn't happen if the string is much less than the
format size. For example,
struct.pack('>32s', 'abc')
works fine. It's only when the size is greater than 20 and
the string is also greater than 20 that things go haywire.
Bill
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=112867&aid=522828&group_id=12867
|