Skip to content

Commit

Permalink
Add workaround for bug in pint with leading zeroes
Browse files Browse the repository at this point in the history
The TaurusValueLineEdit is a ffected by a bug in pint
(hgrecco/pint#614). Work around it by
stripping any leading zeroes from a value string to be passed to
pint's Quantity constructor.
  • Loading branch information
Carlos Pascual committed Jan 24, 2018
1 parent 81b8caf commit 5e7b638
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/taurus/qt/qtgui/input/tauruslineedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5e7b638

Please sign in to comment.