Python API's: sql.Binary() fix
Hi, I may have found a bug in sql.Binary(). Here is the patch: --- pythonize.py 2013-02-03 15:22:09.217186598 +0100 +++ pythonize.py.fix 2013-02-03 15:23:34.613187703 +0100 @@ -119,7 +119,7 @@ def Binary(data): """returns binary encoding of data""" - return ''.join([hex(ord(i))[2:] for i in data]).upper() + return ''.join(["%02X" % ord(i) for i in data]) def DateFromTicks(ticks): """Convert ticks to python Date""" The hex() built-in returns three character string for integers lower than 15. This combined with the original code's [2:] results in corrupt string representations of binary objects having bytes with these values. cheers Mate
i'll have a look at this. On 02/03/2013 03:39 PM, Mate Birkas wrote:
Hi,
I may have found a bug in sql.Binary(). Here is the patch:
--- pythonize.py 2013-02-03 15:22:09.217186598 +0100 +++ pythonize.py.fix 2013-02-03 15:23:34.613187703 +0100 @@ -119,7 +119,7 @@
def Binary(data): """returns binary encoding of data""" - return ''.join([hex(ord(i))[2:] for i in data]).upper() + return ''.join(["%02X" % ord(i) for i in data])
def DateFromTicks(ticks): """Convert ticks to python Date"""
The hex() built-in returns three character string for integers lower than 15. This combined with the original code's [2:] results in corrupt string representations of binary objects having bytes with these values.
cheers Mate
_______________________________________________ developers-list mailing list developers-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/developers-list
-- Gijs Molenaar http://www.astro.uva.nl/people/gijs-molenaar/
On 2013-02-04 17:08, Gijs Molenaar wrote:
i'll have a look at this.
Thanks. But please update correct branch: Oct2012.
On 02/03/2013 03:39 PM, Mate Birkas wrote:
Hi,
I may have found a bug in sql.Binary(). Here is the patch:
--- pythonize.py 2013-02-03 15:22:09.217186598 +0100 +++ pythonize.py.fix 2013-02-03 15:23:34.613187703 +0100 @@ -119,7 +119,7 @@
def Binary(data): """returns binary encoding of data""" - return ''.join([hex(ord(i))[2:] for i in data]).upper() + return ''.join(["%02X" % ord(i) for i in data])
def DateFromTicks(ticks): """Convert ticks to python Date"""
The hex() built-in returns three character string for integers lower than 15. This combined with the original code's [2:] results in corrupt string representations of binary objects having bytes with these values.
cheers Mate
_______________________________________________ developers-list mailing list developers-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/developers-list
_______________________________________________ developers-list mailing list developers-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/developers-list
-- Sjoerd Mullender
participants (3)
-
Gijs Molenaar
-
Mate Birkas
-
Sjoerd Mullender