Do not fail when parsing invalid Decimal value in number entry

Closes #12692
(grafted from f9c0481e7aad3c8229f1660d7367b0edd803389b)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier committed 2023-10-31 21:42:11 +01:00
1 parent c3e99d4948
commit 35c4d729f3
1 file changed
+2 -2
+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
@@ -54,7 +54,7 @@ class NumberEntry(Gtk.Entry, Gtk.Editable):
if text not in ['-', self.__decimal_point]:
try:
value = Decimal(locale.atof(text))
except ValueError:
except (ValueError, InvalidOperation):
return position
if (value and self.__digits is not None
and (round(value, self.__digits) != value