From c2052c11692d223fb5553af1d16f17321ddb5a9d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 9 Nov 2020 07:33:41 -0600 Subject: [PATCH] Give clear error about bit length on import --- jepler_udecimal/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jepler_udecimal/__init__.py b/jepler_udecimal/__init__.py index df23f5c..dad4f32 100644 --- a/jepler_udecimal/__init__.py +++ b/jepler_udecimal/__init__.py @@ -160,6 +160,11 @@ except NameError: if sys.implementation.name == "circuitpython": + if not hasattr(int, "bit_length"): + raise ImportError( + "jepler_udecimal requires int.bit_length. Use CircuitPython 6.0.0-rc.1 or newer." + ) + def _as_integer_ratio(f): m, e = _math.frexp(f) m = round(m * (1 << 53))