aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-11-25 09:47:45 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-11-25 15:49:41 +0100
commit52e3b960b30950ac7bb59bb31e00d6d1038828f1 (patch)
treee48e90c30749972139a4c4a9c7beeaac278fcab4
parentc5e1b51c3349d103ced8dea091cb815e356697d1 (diff)
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 <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/pyside6/PySide6/QtCore/typesystem_core_common.xml4
-rw-r--r--sources/pyside6/tests/QtCore/qlocale_test.py6
2 files changed, 10 insertions, 0 deletions
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 @@
<insert-template name="fix_args,bool*"/>
</inject-code>
</modify-function>
+ <!-- PYSIDE-2133, remove unsigned overloads of toCurrencyString() to
+ ensure float overloads are used -->
+ <modify-function signature="^toCurrencyString\(q?u.*$" remove="all"/>
+ <modify-function signature="^toCurrencyString\(.*short.*$" remove="all"/>
</value-type>
<value-type name="QBitArray">
<add-function signature="__len__">
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()