diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-05-31 07:43:27 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-05-31 07:43:27 (GMT) |
commit | 971ea11e4c2d9b1e204aa37eac3de9cb36333bcf (patch) | |
tree | 482c2c454ded56b1a50c9d329454ac80aeeb17a9 /Modules/_struct.c | |
parent | 14a0952a1ff84b4adefae8381d41fb1799017064 (diff) | |
download | cpython-971ea11e4c2d9b1e204aa37eac3de9cb36333bcf.zip cpython-971ea11e4c2d9b1e204aa37eac3de9cb36333bcf.tar.gz cpython-971ea11e4c2d9b1e204aa37eac3de9cb36333bcf.tar.bz2 |
Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64
Diffstat (limited to 'Modules/_struct.c')
-rw-r--r-- | Modules/_struct.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index 1491b2e..6a3c11f 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -309,24 +309,24 @@ static int _range_error(const formatdef *f, int is_unsigned) { if (is_unsigned == 0) { - long smallest = 0, largest = 0; + Py_ssize_t smallest, largest = 0; Py_ssize_t i = f->size * 8; while (--i > 0) { - smallest = (smallest * 2) - 1; largest = (largest * 2) + 1; } + smallest = -largest - 1; PyErr_Format(StructError, - "'%c' format requires %ld <= number <= %ld", + "'%c' format requires %zd <= number <= %zd", f->format, smallest, largest); } else { - unsigned long largest = 0; + size_t largest = 0; Py_ssize_t i = f->size * 8; while (--i >= 0) largest = (largest * 2) + 1; PyErr_Format(StructError, - "'%c' format requires 0 <= number <= %lu", + "'%c' format requires 0 <= number <= %zu", f->format, largest); } |