[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: PyQt5 bug report: Application fails to start when cwd contains non-ASCII characters
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2023-08-27 10:25:13
Message-ID: fff13e4d0ecd74e82c8cf195fa0330ad () riverbankcomputing ! com
[Download RAW message or body]

On 11/08/2023 12:47, Florian Bruhin wrote:
> Hey,
> 
>> On 8/10/23 11:15, Jean Abou Samra wrote:
>> 
>> [...]
>> 
>> It also occurs on macOS when Qt is installed in the directory in
>> question. The current working directory doesn't matter. The plugin 
>> path
>> and library path appear to be corrupted.
>> 
>> test.py:
>> import os
>> import PyQt5.QtCore as C
>> print(f"\nCWD: {os.getcwd()}")
>> print(f"plugin path:
>> {C.QLibraryInfo.location(C.QLibraryInfo.LibraryLocation.PluginsPath)}")
>> print(f"library paths: {C.QCoreApplication.libraryPaths()}")
>> 
>> $ ./test.py
>> CWD: /private/tmp
>> plugin path:
>> /private/tmp/non-Ã ¤scii/venv/lib/python3.8/site-packages/PyQt5/Qt5/plugins
>> library paths: []
> 
> It looks like PySide had a very similar issue:
> 
> https://bugreports.qt.io/browse/PYSIDE-972
> https://codereview.qt-project.org/c/pyside/pyside-setup/+/313946
> 
> From what I can gather, both PyQt and PySide generate an embedded
> qt.conf to tell Qt where to find its stuff. It looks like PyQt5 uses
> UTF-8 to write those files.
> 
> However, apparently QSettings on Qt 5 only accepts ASCII + Latin-1,
> recommending to use "standard INI escape sequences" for anything 
> outside
> of ASCII:
> 
> https://doc.qt.io/qt-5/qsettings.html#Format-enum
> 
>     Following the philosophy that we should be liberal in what we 
> accept
>     and conservative in what we generate, QSettings will accept Latin-1
>     encoded INI files, but generate pure ASCII files, where non-ASCII
>     values are encoded using standard INI escape sequences.
> 
> So at minimum, I suppose qpycore_qt_conf() in
> qpy/QtCore/qpycore_qt_conf.cpp should use .toLatin1() instead of
> .toLocal8Bit() (= UTF-8 with a UTF-8 locale):
> 
>     static QByteArray qt_conf = qt_dir_name.toLocal8Bit();
> 
> Which would fix this for characters in latin1 at least (though I 
> haven't
> actually tested it). Ideally it'd probably use "standard INI escape
> sequences" (whatever that is... standard and INI in the same sentence 
> is
> somewhat spooky), or perhaps even use QSettings to generate an INI
> (not sure if that's possible, I know nothing about QSettings really).

I've done as you suggest and it fixes the problem on macOS. The fix will 
be in the next PyQt5 snapshot.

Thanks,
Phil
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic