Open ironpythonbot opened 9 years ago
On 2009-03-19 23:35:28 UTC, CurtHagenlocher commented:
This is no major surprise. BitConverter has no overload for Microsoft.Scripting.Math.BigInteger, so the binder looks for the type with the closest matching overload and selects System.BitConverter.GetBytes(System.Single).
On 2010-01-08 02:46:06 UTC, CurtHagenlocher commented:
Here's another overload resolution / conversion issue. The following C# + IronPython code results in the error
TypeError: unsupported operand type(s) for -: 'FloatParallelArray' and 'float' It should cast the Double to a Single. This already happens for non-operator calls.
public class FloatParallelArray { public static FloatParallelArray operator -(FloatParallelArray a1, FloatParallelArray a2); public static FloatParallelArray operator -(FloatParallelArray a, float f); public static FloatParallelArray operator -(float f, FloatParallelArray a); public static FloatParallelArray operator -(FloatParallelArray a); }
f = FloatParallelArray() g = f - 0.5 # Generates error
On 2011-08-31 12:27:28 UTC, skottmckay commented:
Note this can be worked around by explicitly choosing the overload
x = long(999000999000) System.BitConverter.GetBytes.OverloadsSystem.UInt64
--------------------------------------------------------------------------
IP VERSION AFFECTED: 2.6 Alpha 1
BUILD TYPE: All
FLAGS PASSED TO IPY.EXE: Any
OPERATING SYSTEM: All
CLR VERSION: .NET 2.0 SP1
--------------------------------------------------------------------------
BRIEF DESCRIPTION:
The number of bytes detected by the BCL static method, System.BitConverter.GetBytes,
for Python longs is always four regardless of how small/big the Python long is. Also,
the value returned by GetBytes for longs does not follow the same pattern as Int16, Int32,
etc.
--------------------------------------------------------------------------
REPRODUCTION SNIPPET:
Length of the ByteArray object returned by GetBytes looks wrong
IronPython 2.6 Alpha DEBUG (2.6.0.1) on .NET 2.0.50727.3053
Type "help", "copyright", "credits" or "license" for more information.
System.BitConverter.GetBytes(long(1))
Array[Byte](%28<System.Byte object at 0x0000000000000075 [0]>, <System.Byte object at 0x0000000000000076 [0]>, <System.Byte object at 0x000000
0000000077 [128]>, <System.Byte object at 0x0000000000000078 [63]>%29)
Another weird one using System.Threading.Timer:
Timer(func, None, 100.1, 0) # throws
Timer(func, None, 100, 0) # ok
Timer(func, None, 100, 0).Change(100.1) # ok
Change has all the same numeric overloads as Timer. But the difference is that Timer also includes a function whose conversion is evaluated at a different level. Maybe we need to move function conversins up to an earlier narrowing level?
Work Item Details
Original CodePlex Issue: Issue 21676 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Mar 17, 2009 at 4:56 PM Reported by: dfugate Updated on: Feb 22, 2013 at 2:13 AM Updated by: skottmckay Test: Needed Thanks: Haibo Luo