[issue1023290] Conversion of longs to bytes and vice-versa.

Mark Dickinson report at bugs.python.org
Fri Apr 2 13:20:32 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

The backport wasn't as straightforward as I'd hoped, and we've pretty much run out of time for 2.7.

One issue is that long.from_bytes(b, ...) converts b to bytes type using the equivalent of "bytes(b)".  This doesn't work well in 2.7 (consider "bytes([255, 0, 0])" for example.  So different code is needed in 2.7 when interpreting an arbitrary Python object as a sequence of bytes.

Perhaps the 2.7 version could just iterate over the given object, and raise an exception if any of the iterates are not integers in the range [0, 256).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1023290>
_______________________________________


More information about the Python-bugs-list mailing list