diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-08-18 12:24:51 +0200 |
---|---|---|
committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-08-25 09:21:33 +0200 |
commit | 35c96115cb4fb71fcc263abf43099dd712187080 (patch) | |
tree | 035aca30a2fb0afa5277d00c05b8aadf0e286595 /sources/pyside6/PySide6/QtCore/typesystem_core_common.xml | |
parent | f3f8939f347370dbd2738ecb536543bf8cff4a09 (diff) |
PySide: Fix QLocale::system() in macOS
- QSystemLocale for macOS relies on CFBundleAllowMixedLocalizations/
CFBundleLocalizations in the Info.plist file for the C++
Application bundle, as seen from
1d3ae5f0e98f252214d20ce8561533891311a71f. Python being an
interpreted language, there is no application bundle unless the
application is deployed. As such a Python application in macOS
relies on the Info.plist file of the Python interepreter. This
Info.plist file is a read-only file and hence it is not
possible/recommended to patch the Info.plist file of the Python
interpreter at runtime.
The issue has been raised upstream in CPython and can be tracked
here: https://github.com/python/cpython/issues/108269
- A possible solution/hack is therefore to use to POSIX environment
variables for macOS, for Qt for Python. This is also what the Python
locale module does.
See: https://github.com/python/cpython/blob/3.11/Lib/locale.py#L534
For other Unix systems, QLocale::system() uses the POSIX environment
variables, just like Python's locale module.
- For Windows and Linux, QSystem::locale() remains unchanged.
- The idea here is to obtain the system locale from the Python locale
module, and use the result to initialize and return a QLocale
object.
- As an extra, for qrunnable_create fix the typo - snipped to
snippet.
Fixes: PYSIDE-2419
Pick-to: 6.5 6.2
Change-Id: I12b16e824ddba21d1ebcd0695262c1dc0cc61eb2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'sources/pyside6/PySide6/QtCore/typesystem_core_common.xml')
-rw-r--r-- | sources/pyside6/PySide6/QtCore/typesystem_core_common.xml | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index c801aef3f..e92680b68 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -1332,10 +1332,31 @@ <modify-function signature="toString(qulonglong)const" remove="all"/> <modify-function signature="toString(ushort)const" remove="all"/> <modify-function signature="toString(unsigned int)const" remove="all"/> + <modify-function signature="system()" remove="all"/> <!--### --> <extra-includes> <include file-name="QDate" location="global"/> </extra-includes> + <add-function signature="system()" return-type="QLocale" static="yes"> + <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" + snippet="qlocale_system"/> + <inject-documentation mode="append" format="target"> + Returns a QLocale object initialized to the system locale. + + The system locale may use system-specific sources for locale data, where available, + otherwise falling back on QLocale's built-in database entry for the language, script and + territory the system reports. + + For example, on Windows, this locale will use the decimal/grouping characters and + date/time formats specified in the system configuration panel. + + .. note:: Qt for Python on macOS will not reflect the user's region and language + preferences though QLocale::system(), but will instead reflect the environment + variables POSIX uses to specify locale, similar to Python's locale module. + + See also c(). + </inject-documentation> + </add-function> <modify-function signature="toTime(QString,QLocale::FormatType)const"> <modify-argument index="2"> <rename to="format"/> |