From 52e3b960b30950ac7bb59bb31e00d6d1038828f1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 25 Nov 2022 09:47:45 +0100 Subject: PySide6: Fix float type overloads of QLocale.toCurrencyString() QLocale.toCurrencyString() has a plethora of overloads from short/ushort to long long and float types. Since the overload sorter currently has no rules for preferring float over unsigned integer types, an unsigned conversion was done for float types with decimals, resulting in decimals being lost. This could arguably be fixed by adding rules for preferring float over unsigned integer types. However, since Python only knows int and float, it does not really make sense to generate a complex overload logic. Remove the unsigned and short overloads instead. Fixes: PYSIDE-2133 Pick-to: 6.4 6.2 Change-Id: Id2ef2ec02f4f962606851faf237d80196872eed2 Reviewed-by: Qt CI Bot Reviewed-by: Cristian Maureira-Fredes --- sources/pyside6/PySide6/QtCore/typesystem_core_common.xml | 4 ++++ sources/pyside6/tests/QtCore/qlocale_test.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index 3af5cd6a4..d9a6c8435 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -1429,6 +1429,10 @@ + + + diff --git a/sources/pyside6/tests/QtCore/qlocale_test.py b/sources/pyside6/tests/QtCore/qlocale_test.py index 89d9a0e71..3d3425445 100644 --- a/sources/pyside6/tests/QtCore/qlocale_test.py +++ b/sources/pyside6/tests/QtCore/qlocale_test.py @@ -46,6 +46,12 @@ class QLocaleTestToNumber(unittest.TestCase): obj = QLocale(QLocale.C) self.assertTrue(not obj.toULongLong('-37')[1]) + def testToCurrencyString(self): + """PYSIDE-2133, do not use int overload, dropping decimals.""" + en_locale = QLocale("en_US") + value = en_locale.toCurrencyString(1234.56) + self.assertEqual(value, "$1,234.56") + if __name__ == '__main__': unittest.main() -- cgit v1.2.3