From 5e7b6385035bc37fd580a4ccdf357386703d2ee7 Mon Sep 17 00:00:00 2001 From: Carlos Pascual Date: Wed, 24 Jan 2018 11:23:53 +0100 Subject: [PATCH] Add workaround for bug in pint with leading zeroes The TaurusValueLineEdit is a ffected by a bug in pint (https://github.com/hgrecco/pint/issues/614). Work around it by stripping any leading zeroes from a value string to be passed to pint's Quantity constructor. --- lib/taurus/qt/qtgui/input/tauruslineedit.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/taurus/qt/qtgui/input/tauruslineedit.py b/lib/taurus/qt/qtgui/input/tauruslineedit.py index 76b421265..160b62934 100755 --- a/lib/taurus/qt/qtgui/input/tauruslineedit.py +++ b/lib/taurus/qt/qtgui/input/tauruslineedit.py @@ -239,6 +239,10 @@ def getValue(self): model_format = model_obj.data_format if model_type in [DataType.Integer, DataType.Float]: try: + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # workaround for https://github.com/hgrecco/pint/issues/614 + text = text.lstrip('0') or '0' + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ q = Quantity(text) # allow implicit units (assume wvalue.units implicitly) if q.unitless: