From d7dd75e833fc99ad75e10220a5ec8f03d64ee5bd Mon Sep 17 00:00:00 2001 From: Steve Fan Date: Tue, 11 Jan 2022 10:12:40 +0800 Subject: [PATCH] comm_kernel: fix off-by-one error for numeric value range check --- artiq/coredevice/comm_kernel.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/artiq/coredevice/comm_kernel.py b/artiq/coredevice/comm_kernel.py index 1b0111c49..df080d2d1 100644 --- a/artiq/coredevice/comm_kernel.py +++ b/artiq/coredevice/comm_kernel.py @@ -437,12 +437,12 @@ class CommKernel: self._write_bool(value) elif tag == "i": check(isinstance(value, (int, numpy.int32)) and - (-2**31 < value < 2**31-1), + (-2**31 <= value < 2**31), lambda: "32-bit int") self._write_int32(value) elif tag == "I": check(isinstance(value, (int, numpy.int32, numpy.int64)) and - (-2**63 < value < 2**63-1), + (-2**63 <= value < 2**63), lambda: "64-bit int") self._write_int64(value) elif tag == "f": @@ -451,8 +451,8 @@ class CommKernel: self._write_float64(value) elif tag == "F": check(isinstance(value, Fraction) and - (-2**63 < value.numerator < 2**63-1) and - (-2**63 < value.denominator < 2**63-1), + (-2**63 <= value.numerator < 2**63) and + (-2**63 <= value.denominator < 2**63), lambda: "64-bit Fraction") self._write_int64(value.numerator) self._write_int64(value.denominator)