Skip to content

Decode locale-encoded descriptions.

The translated description returned by libapt-pkg is, unlike other fields, locale-encoded (see apt-pkg/deb/debrecords.cc). As such, try decoding that description with the current locale.

This wasn't such an issue with python2, as the locale defaulted to ASCII, but fails pretty badly with python3:

  1. make sure you have a non-utf8 locale, if not add/uncomment en_US ISO-8859-1 in /etc/locale.gen and re-run locale-gen
  2. env LC_ALL=en_US python3 -c 'import apt; apt.Cache().get("gosa").versions[0].description'
  3. You will get an exception in the C++ bindings which erroneously try to decode that one field as UTF-8.

Alternatively, that test case can be reproduced under python2.7 by calling locale.setlocale(locale.LC_ALL, "en_US") prior to doing the same apt-cache call. In this case, the exception is not raised, but blindly converted to text.

Merge request reports

Loading