From bba921329de77d49db02c63ab61b4bbd0c42f00f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 17 Mar 2023 10:53:02 +1000 Subject: [PATCH] proto: skip the bitmask check if on old python versions int.bit_count() requires Python 3.10, so let's skip it where not available. --- proto/ei-scanner | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/proto/ei-scanner b/proto/ei-scanner index ca11203..ae42b0c 100755 --- a/proto/ei-scanner +++ b/proto/ei-scanner @@ -277,8 +277,11 @@ class Enum: if self.is_bitfield: if e.value < 0: raise ValueError("Bitmasks must not be less than zero") - if e.value.bit_count() > 1: - raise ValueError("Bitmasks must have exactly one bit set") + try: + if e.value.bit_count() > 1: + raise ValueError("Bitmasks must have exactly one bit set") + except AttributeError: + pass # bit_count() requires Python 3.10 self.entries.append(entry)