Hi, @kibi, tl;dr: my test results about this problem in similar code confirm the problem and validate Iain's fix ⇒ +1 to apply :)
Cyril Brulebois: > Looping in the Perl team for additional eyes and also awareness. Other > packages might be affected, and it might make sense to conduct some > sources.d.o/codesearch-based check… >From Iain's report I understand that since Perl 5.28, gettext() calls are cached, so after switching the locale, in order to get correct results, one needs to invalidate the cache somehow, e.g. by calling bindtextdomain() and then textdomain(). I've looked for problematic patterns on codesearch: https://codesearch.debian.net/search?q=filetype%3Aperl+ENV{LANGUAGE} https://codesearch.debian.net/search?q=filetype%3Aperl+ENV%7B%27LANGUAGE%27%7D https://codesearch.debian.net/search?q=filetype%3Aperl+ENV%7B%22LANGUAGE%22%7D https://codesearch.debian.net/search?q=filetype%3Aperl+setlocale%5C%28 … and checked a subset of the results. I've only spotted two potentially problematic cases. 1. sympa: dgettext sub in src/lib/Sympa/Language.pm Only works because the BEGIN block explicitly selects one of the 'gettext_dumb' and 'gettext_pp' implementations. Without this, or if using the default implementation ('gettext_xs'), Sympa::Language::dgettext() would return cached results, unless using the trick proposed by Iain to invalidate the cache. 2. texinfo: tp/Texinfo/Report.pm Similarly to Sympa, it should work fine because the code explicitly selects the 'gettext_pp' implementation… with a comment that reads "we want a reliable way to switch locale, so we don't use the system gettext". I've searched for 'gettext_xs' and only found relevant occurrences in its own implementation (libintl-perl). No package seems to explicitly pick that implementation. But that implementation is the default so any package that uses Locale::Messages or a higher-level Perl API to gettext is potentially affected. I hope that my search for $ENV{LANGUAGE} and friends covered all those that dynamically switch locales at runtime. Potentially relevant upstream issues: https://github.com/gflohr/libintl-perl/issues/3 https://rt.cpan.org/Public/Bug/Display.html?id=120446 (Some of the issues there are attributed to the local environment but I suspect some of them might actually be caused by the problem Iain found.) Cheers, -- intrigeri