[IronPython] Some minor int/long bugs
Dan Eloff
dan.eloff at gmail.com
Wed May 7 19:54:11 CEST 2008
I found this difference between IronPython and CPython in struct:
CPython
>>> struct.unpack('I','\xedd\x02\x00')
(156909,)
IronPython 2.0b1
>>> struct.unpack('I','\xedd\x02\x00')
(156909L,)
It seems that even although unpack('I', '\xff'*4) has to be a long,
for values of sys.maxint or below, CPython always returns an int.
Python ints and longs behave very similarily, so most of the time this
matters little. Enter bug #2.
ToString(format) doesn't work on python longs, but it will work on
python ints (as long as clr is imported.)
I would suggest that because sometimes it does matter whether you have
an int or a long, it would be best to fix the discrepancy in struct.
As for supporting ToString(format) on longs, I don't see this as being
easy or high priority, perhaps it would be enough to implement it by
converting the long to System.Decimal, and just using it's
ToString(format) which works perfectly.
I will report these on Codeplex.
-Dan
More information about the Ironpython-users
mailing list