Do not fail when parsing invalid Decimal value in number entry

Closes #12692
This commit is contained in:
Cédric Krier
2023-10-31 21:42:11 +01:00
parent 25f2f35fea
commit 689382daeb
+2 -2
View File
@@ -2,7 +2,7 @@
# this repository contains the full copyright notices and license terms.
import gettext
import locale
from decimal import Decimal
from decimal import Decimal, InvalidOperation
from gi.repository import Gdk, GObject, Gtk
@@ -62,7 +62,7 @@ class NumberEntry(Gtk.Entry, Gtk.Editable):
if text not in ['-', self.__decimal_point, self.__thousands_sep]:
try:
value = Decimal(locale.delocalize(text, self.monetary))
except ValueError:
except (ValueError, InvalidOperation):
return position
if (value and self.__digits is not None
and (round(value, self.__digits) != value