[IronPython] array.fromfile

JoeSox joesox at gmail.com
Sat Feb 24 20:30:09 CET 2007


On 2/24/07, JoeSox <joesox at gmail.com> wrote:
> I really don't wish to modify the natural language processing tool
> module any more that I already have.  Is it really necessary for
> IronPython to change the "minimum" sizes of the array types? (and
> hopefully this is my problem, I guess I will need to modify array.cs
> to truly find out)

Well, I changed the typecode's in array.cs to resemble CPython's but
it seems ArrayData class can not handle the change. I haven't examined
the ArrayData in detail.  Maybe I need to change 'L' to UInt64.  Here
are my results for anyone interested:
----array.cs changes:
                    case 'c': data = new ArrayData<char>(); break;
                    case 'b': data = new ArrayData<sbyte>(); break;
                    case 'B': data = new ArrayData<byte>(); break;
                    case 'u': data = new ArrayData<char>(); break;
                    case 'h': data = new ArrayData<short>(); break;
                    case 'H': data = new ArrayData<ushort>(); break;
                    case 'i': data = new ArrayData<Int16>(); break;
                    case 'I': data = new ArrayData<UInt16>(); break;
                    case 'l': data = new ArrayData<Int32>(); break;
                    case 'L': data = new ArrayData<UInt32>(); break;
                    case 'f': data = new ArrayData<float>(); break;
                    case 'd': data = new ArrayData<double>(); break;
---exception:
System.OverflowException was caught
  Message="couldn't convert <type 'UInt64'> to <type 'UInt32'>"
  Source="IronPython"
  StackTrace:
       at IronPython.Modules.ArrayModule.PythonArray.ArrayData`1.GetValue(Object
value) in C:\Documents and Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Modules\array.cs:line
566
       at IronPython.Modules.ArrayModule.PythonArray.ArrayData`1.Append(Object
value) in C:\Documents and Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Modules\array.cs:line
579
       at IronPython.Modules.ArrayModule.PythonArray.FromStream(Stream
ms) in C:\Documents and Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Modules\array.cs:line
542
       at IronPython.Modules.ArrayModule.PythonArray.FromString(String
s) in C:\Documents and Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Modules\array.cs:line
216
       at IronPython.Modules.ArrayModule.PythonArray.FromFile(PythonFile
f, Int32 n) in C:\Documents and Settings\Joseph\My Documents\Visual
Studio 2005\Projects\IronPython-1.1B1\Src\IronPython\Modules\array.cs:line
204
       at FromFile##120(Object , Object , Object )
       at IronPython.Runtime.Calls.CallTarget3.Invoke(Object arg0,
Object arg1, Object arg2)
       at IronPython.Runtime.Calls.FastCallable3.CallInstance(ICallerContext
context, Object arg0, Object arg1, Object arg2) in C:\Documents and
Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Calls\FastCallable.Generated.cs:line
654
       at IronPython.Runtime.Calls.BoundBuiltinFunction.Call(ICallerContext
context, Object arg0, Object arg1) in C:\Documents and
Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Calls\BuiltinFunction.Generated.cs:line
82
       at IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext
context, Object func, Object arg0, Object arg1) in C:\Documents and
Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Operations\Ops.Generated.cs:line
92
       at CNUMontyLexiconFast.array_fromfile$f343(FunctionEnvironment32Dictionary
$env, Object self, Object file_ptr, Object array_ptr, Object length,
Object java_p, Object java_code, Object endian_order) in C:\Documents
and Settings\Joseph\My Documents\Visual Studio
2005\Projects\CNU\CNUtils2Demo\CNUtils2Demo\bin\Debug\CNUMontyLexiconFast.py:line
255
       at CNUMontyLexiconFast.array_fromfile$f343(FunctionEnvironment32Dictionary
, Object[] )
       at IronPython.Runtime.Calls.FunctionN.Call(ICallerContext
context, Object[] args) in C:\Documents and Settings\Joseph\My
Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Calls\Function.cs:line
721
       at IronPython.Runtime.Calls.FastCallable.Call(Object[] args) in
C:\Documents and Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Calls\FastCallable.cs:line
113
       at IronPython.Runtime.Calls.PythonFunction.Call(ICallerContext
context, Object[] args, String[] kwNames) in C:\Documents and
Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Calls\Function.cs:line
430
       at IronPython.Runtime.Operations.Ops.Call(ICallerContext
context, Object func, Object[] args, String[] names) in C:\Documents
and Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Operations\Ops.cs:line
1428
       at IronPython.Runtime.Calls.Method.Call(ICallerContext context,
Object[] args, String[] names) in C:\Documents and Settings\Joseph\My
Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Calls\Function.cs:line
996
       at IronPython.Runtime.Operations.Ops.Call(ICallerContext
context, Object func, Object[] args, String[] names) in C:\Documents
and Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Operations\Ops.cs:line
1428
       at CNUMontyLexiconFast.load_fastlexicon$f332(FunctionEnvironment32Dictionary
$env, Object self) in C:\Documents and Settings\Joseph\My
Documents\Visual Studio
2005\Projects\CNU\CNUtils2Demo\CNUtils2Demo\bin\Debug\CNUMontyLexiconFast.py:line
101
       at IronPython.Runtime.Calls.Function1.Call(ICallerContext
context, Object arg0) in C:\Documents and Settings\Joseph\My
Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Calls\Function.Generated.cs:line
127
       at IronPython.Runtime.Calls.PythonFunction.CallInstance(ICallerContext
context, Object arg0) in C:\Documents and Settings\Joseph\My
Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Calls\Function.Generated.cs:line
48
       at IronPython.Runtime.Calls.Method.Call(ICallerContext context)
in C:\Documents and Settings\Joseph\My Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Calls\Function.Generated.cs:line
522
       at IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext
context, Object func) in C:\Documents and Settings\Joseph\My
Documents\Visual Studio
2005\Projects\IronPython-1.1B1\Src\IronPython\Runtime\Operations\Ops.Generated.cs:line
78
       at CNUMontyLexiconFast.__init__$f330(FunctionEnvironment32Dictionary
$env, Object self) in C:\Documents and Settings\Joseph\My
Documents\Visual Studio
2005\Projects\CNU\CNUtils2Demo\CNUtils2Demo\bin\Debug\CNUMontyLexiconFast.py:line
37 (snipped)

-- 
Thanks, Joe



More information about the Ironpython-users mailing list