• Bug#1108929: pyqt5-dev-tools: pylupdate_main.py fail when no locale is

    From Petter Reinholdtsen@21:1/5 to All on Tue Jul 8 08:00:02 2025
    Package: pyqt5-dev-tools
    Version: 5.15.11+dfsg-2
    Severity: important
    Tags: patch

    Currently the reproducible build of opensnitch fail, as can be seen on
    <URL: https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/opensnitch.html >:

    make[2]: Entering directory
    '/build/reproducible-path/opensnitch-1.6.9/ui/i18n'

    /usr/lib/python3/dist-packages/PyQt5/pylupdate_main.py:73:
    DeprecationWarning: 'locale.getdefaultlocale' is deprecated and slated
    for removal in Python 3.15. Use setlocale(), getencoding() and
    getlocale() instead.

    encoding = locale.getdefaultlocale()[1]
    Traceback (most recent call last):
    File "<frozen runpy>", line 198, in _run_module_as_main
    File "<frozen runpy>", line 88, in _run_code
    File "/usr/lib/python3/dist-packages/PyQt5/pylupdate_main.py", line
    251, in <module>
    main()
    ~~~~^^
    File "/usr/lib/python3/dist-packages/PyQt5/pylupdate_main.py", line
    201, in main
    _encoded_path(
    ~~~~~~~~~~~~~^
    QDir.current().absoluteFilePath(t)),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/PyQt5/pylupdate_main.py", line
    77, in _encoded_path

    return path.encode(encoding)
    ~~~~~~~~~~~^^^^^^^^^^
    LookupError: unknown encoding: C

    As far as I can tell, this is caused by the following code fragment in /usr/lib/python3/dist-packages/PyQt5/pylupdate_main.py:

    def _encoded_path(path):
    encoding = locale.getdefaultlocale()[1]
    if encoding is None:
    # fall back to the C encoding
    encoding = "C"
    return path.encode(encoding)

    The problem seem to be that 'C' is not working as a encoding string.
    Perhaps it would be better to use 'utf-8' instead, ref
    <URL: https://docs.python.org/3/howto/unicode.html >? In other words, something like this:

    --- /usr/lib/python3/dist-packages/PyQt5/pylupdate_main.py 2023-02-07 19:00:26.000000000 +0100
    +++ /tmp/pylupdate_main.py 2025-07-08 07:54:53.554575899 +0200
    @@ -73,7 +73,7 @@
    encoding = locale.getdefaultlocale()[1]
    if encoding is None:
    # fall back to the C encoding
    - encoding = "C"
    + encoding = "utf-8"
    return path.encode(encoding)

    The warning make me suspect it should switch to getencoding() instead,
    though. :)

    --
    Happy hacking
    Petter Reinholdtsen

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)