[IronPython] Critical bug in binascii

Dino Viehland dinov at exchange.microsoft.com
Fri Jun 2 10:10:54 PDT 2006


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


More information about the users mailing list