Different QLocale.decimalPoint values, little-endian (amd64, arm64, etc) vs. big-endian (s390x)
Phil Thompson
phil at riverbankcomputing.com
Fri May 23 11:40:52 BST 2025
On 21/05/2025 12:38, Dmitry Shachnev wrote:
> Hi,
>
> Forwarding a bug report that I received in Debian [1].
>
> The following code correctly returns a comma on little endian systems:
>
> >>> from PyQt6.QtCore import QLocale
> >>> QLocale(QLocale.Language.Dutch, QLocale.Script.LatinScript,
> QLocale.Country.Netherlands).decimalPoint()
> ','
>
> But on big endian systems it returns a dot:
>
> >>> from PyQt6.QtCore import QLocale
> >>> QLocale(QLocale.Language.Dutch, QLocale.Script.LatinScript,
> QLocale.Country.Netherlands).decimalPoint()
> '.'
>
> And an equivalent C++ program consistenly returns comma on both
> platforms:
>
> #include <QtCore/QLocale>
> #include <QtCore/QTextStream>
>
> int main() {
> QTextStream(stdout) << QLocale(QLocale::Dutch,
> QLocale::LatinScript, QLocale::Netherlands).decimalPoint() <<
> Qt::endl;
> return 0;
> }
>
> Also, it works fine with PyQt5 and PySide6.
>
> Package versions:
>
> - PyQt6 v6.9.0
> - SIP v6.10.0
> - PyQt-builder v1.18.1
>
> I have access to a big endian box so I can test a potential patch if
> needed.
>
> [1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1088101
>
> --
> Dmitry Shachnev
I'm not convinced. PyQt6 doesn't do anything special - it's simply
converting a QString to a Python str and if this is broken then hardly
anything would work. It's also suspicious that the wrong value isn't
garbled but is what would be the correct value in the majority of
locales. That suggests an environmental problem.
What about other QLocale calls that return a QString (eg.
nativeLanguageName())?
Phil
More information about the PyQt
mailing list