Skip to content

Call dpkg with LC_ALL=C.UTF8 set

Benjamin Drung requested to merge bdrung/python3-defaults:fix-utf-decode into master

from_package calls /usr/bin/dpkg -L and expects the output to be UTF-8, but dpkg's output will the in the user's locale. This could lead to unicode decode errors:

Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/python3/debpython/files.py", line 54, in from_package
    stdout = str(stdout, 'utf-8')
             ^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 2417: invalid continuation byte

So set LC_ALL=C.UTF8 when calling dpkg.

Bug-Ubuntu: https://launchpad.net/bugs/2075337

Edited by Benjamin Drung

Merge request reports

Loading