[issue27623] int.to_bytes() and int.from_bytes(): raise ValueError when bytes count is zero
Martin Panter
report at bugs.python.org
Thu Jul 28 01:11:25 EDT 2016
Martin Panter added the comment:
I agree that the signed conversion cases should be an error.
However the unsigned case would break working code that I have written for bijective numeration. See _bytes_to_int() and _int_to_bytes() in Issue 20132, inc-codecs.diff, for example. Since non-zero unsigned conversions work by converting
N bytes <-> 0 <= value < 2^N
For N = 0, there is only one possible value, 0.
----------
nosy: +martin.panter
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27623>
_______________________________________
More information about the Python-bugs-list
mailing list