-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 reassign 840610 python3 3.5.1-4 retitle 840610 python inconsistently handles the LANGUAGE env var severity 840610 serious affects 840610 apt-listchanges thanks
[Severity serious, because I believe internationalization is one of priorities of Debian, and this bug makes localized versions of python-based applications unreliable] Ph. Marek writes: > Normally, I'm using de_AT.UTF-8. For reporting a bug I set "export > LC_ALL=C", but on the next apt-get invocations I get error > messages: > > $ apt-get install -t experimental rakudo ... Fetched 4146 kB in 2s > (1434 kB/s) apt-listchanges: Lese Changelogs... [...] File > "/usr/share/apt-listchanges/ALCLog.py", line 36, in info > print(_("apt-listchanges: %(msg)s") % {'msg': msg}, > file=sys.stdout); UnicodeEncodeError: 'ascii' codec can't encode > character '\xfc' in position 68: ordinal not in range(128) > (Reading database ... 556786 files and directories currently > installed.) > > (never mind the single German line in there ;) Actually this is the most important line of your bug report ;) In LC_ALL=C, it is "Reading changelogs..." that should be printed instead of its translation. Please note that dpkg prints "Reading database ...", not "Lese Datenbank ...". I can easily reproduce this weird behaviour by setting both LANGUAGE=de_DE.UTF-8 and LC_ALL=C, and this is the only way I can do thi s. According to GNU gettext documentation[1]: "The variable LANGUAGE is ignored if the locale is set to āCā." But apparently this does not work this way in python - it looks like print() ignores the variable, but gettext.gettext() does not, what is pretty inconsistent, and leads to errors: [16]/home/robert> LANGUAGE=de_AT.UTF8 LC_ALL=C python3 Python 3.5.2+ (default, Sep 22 2016, 12:18:14) [GCC 6.2.0 20160927] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import locale >>> import gettext >>> locale.setlocale(locale.LC_ALL, '') 'C' >>> gettext.textdomain("apt-listchanges") 'apt-listchanges' >>> print(gettext.gettext('apt-listchanges: changelogs for %s')) Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 29: ordinal not in range(128) Regards, robert [1] https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-varia ble.html -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJYAp9xAAoJEGMd51U76K/ULBMP/i7L+sI0azEeF2XX8+ocThUL z0zD+n+jI6+devAU+pQhsnO1mPspU6FUL5LupU0kbjJKmv8TuHWpmg6rnecSdJYT iE8KGG+gCXB/2o8Ya1oD3HiLzh7AHfEOrnMjoqIelQOx8OiDvZnK/6cRHAbBOZqV /G88qmk6QdtPPYBfRekCfiRzPn8nu57fkz+FbZag43lqkdqYMuj+XidKRG262cR0 ibgtQ3Jni+IiBhmuNhMGY+tE7MSWoBAmrI4slc5O/6PlZWEVIMeHwGkb2CKsTUcX C24dFelMC/CWQyidA0ao3LOQz9drzftO21FMqu9MAuwiCsTdSpOMH+33sGbb2qjg i2K/mDamj7EALkNA3mjKiZpw51JwtykukdN7igSHSFTeBiUgDxkvZuvyYapt6keI 3vEzT/JCrzfkutC2VxbcPreq3fbQuRjb2gW1GHd3Yuv/h1LTQlXqV3hoGv1ppNq1 4IbQHx+awuareYLDInqgjhsHVZCnlun9Sj3OFnuBi3ziDyw+Dj7ALU2g2bjhBle7 CwB07ZZOSs/mEceFlnj/AVt+0yzDSFt8koqw1vh8DkHz8Gws1oPuHZoB1XXtWHUG dc24TIRv0GuT9giEW+6LWMWPmQd9qmdUY0ZqgVtFz3Df1BvF4LPJaqvzWFrrdpNV Fr/nIt37K6yblTB5OTb2 =Ggrh -----END PGP SIGNATURE-----