summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-06-13 20:50:08 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-06-13 20:50:08 (GMT)
commit898cf85c25de57a0c40bd9bedc00519674d09457 (patch)
treeb4d3ecf1a46e632b632817b6db747f19b144daa5 /Objects
parent9cb0c38fff05776f598ebfb67a60abc3bff629e2 (diff)
downloadcpython-898cf85c25de57a0c40bd9bedc00519674d09457.zip
cpython-898cf85c25de57a0c40bd9bedc00519674d09457.tar.gz
cpython-898cf85c25de57a0c40bd9bedc00519674d09457.tar.bz2
_PyLong_AsByteArray: added assert that the input is normalized. This is
outside the function's control, but is crucial to correct operation.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/longobject.c6
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;