diff options
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 3c22470..f8a9129 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -358,7 +358,11 @@ _PyLong_AsByteArray(PyLongObject* v, pincr = -1; } - /* Copy over all the Python digits. */ + /* Copy over all the Python digits. + It's crucial that every Python digit except for the MSD contribute + exactly SHIFT bits to the total, so first assert that the long is + normalized. */ + assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0); j = 0; accum = 0; accumbits = 0; |