[IronPython] array.fromfile

Dino Viehland dinov at exchange.microsoft.com
Sat Feb 24 12:49:15 PST 2007


Ok, L/l are always 32-bits on CPython on Windows at least, so we'll match that behavior.  I also noticed an additional bug where we aren't returning BigInt's from these so we'll fix that too.

________________________________________
From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland [dinov at exchange.microsoft.com]
Sent: Saturday, February 24, 2007 12:25 PM
To: Discussion of IronPython
Subject: Re: [IronPython] array.fromfile

Unfortunately there are several switch statements that will need to be updated.  They are in CreateData (generic type), ToStream (cast), FromStream (call Read?Int32).  If you update all 3 you should be consistent then.

If I had to take a guess here I would think maybe there's an earlier read from an array that's driving the # of elements to be read later.

I'm not opposed to changing the sizes of these to match CPython but I suspect we can never make the sizes 100% compatible across all architectures on all platforms.  Technically this IS a bug in the module you're using - it shouldn't expect the sizes to be fixed.  We can make these 4 byte values but I suspect we'll have differences on x64.  We can make them platform dependent but not all platforms have the same definitions for the size of "long".  In particular I believe Windows defines this as being 4 bytes and most other platforms choose 8 bytes.  Based upon that investigating I'll update the sizes so we can be more compatible.  But I'd love to hear if updating all 3 fixes your problem.
________________________________________
From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of JoeSox [joesox at gmail.com]
Sent: Saturday, February 24, 2007 11:30 AM
To: Discussion of IronPython
Subject: Re: [IronPython] array.fromfile

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
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the users mailing list