From 64347290fb61d92b73653f47c963b72986627be5 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 cdb54a118..bb8ed82fc 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)