[IronPython] Critical bug in binascii

Aude Espesset aude at microsoft.com
Fri Jun 2 20:15:32 CEST 2006


Thanks, it's fixed!

________________________________

From: users-bounces at lists.ironpython.com on behalf of Dino Viehland
Sent: Fri 6/2/2006 10:10 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Critical bug in binascii



Thanks for the bug report, we'll have this one fixed for the next release.

The fix is actually quite trivial if you want to update your copy of IronPython & rebuild.  In IronPython\Modules\binascii.cs the function EncodeHex needs to have its call to AppendFormat be replaced with:

                sb.AppendFormat("{0:x2}", (int)data[i]);

(we're just missing the 2 which guarantees we right out 2 characters all the time).


-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Aude Espesset
Sent: Friday, June 02, 2006 9:19 AM
To: users at lists.ironpython.com
Subject: [IronPython] Critical bug in binascii

Hi all,

I'm trying to read some fields in a binary file and convert them to hexadecimal numbers. The conversion seems to work most of the time but not always. It doesn't crash, it just returns the wrong answer:-(

Here's an example:

*

In CPython :

>>> import binascii

>>> a = '\x00\x00\x10\x00'

>>> b = binascii.b2a_hex(a)

>>> b

'00001000'

>>> int(b,16)

4096



The same thing in IronPython (beta 7):

>>> import binascii

>>> a = '\x00\x00\x10\x00'

>>> b = binascii.b2a_hex(a)

>>> b

'00100'

>>> int(b,16)

256



Aude

_______________________________________________
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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 5210 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060602/75e1fb16/attachment.bin>


More information about the Ironpython-users mailing list