perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

Locale fallback cleanup

Open bram-perl opened this issue 2 years ago • 2 comments

Cleanup some code in locale.c: Perl_init_i18nl10n which sets/prints the fallback locale that was used.

Note: this does alter the output of the message slightly, if this is not wanted then that can easily be patched.

Old output:

	$ LC_ALL= LANG=C LC_PAPER=aa_BB perl -e1
	(...)
	perl: warning: Falling back to the standard locale ("C").

New output:

	$ LC_ALL= LANG=C LC_PAPER=aa_BB ./perl -e1
	(...)
	perl: warning: Falling back to a fallback locale (LANG) ("C").

I.e. the output now includes the ENV variable that contains the fallback locale (in the output above: LANG)

(Suggestions for a better name for trial_locales_struct are also welcome)

bram-perl avatar Aug 07 '22 13:08 bram-perl

otherwise LGTM

khwilliamson avatar Aug 07 '22 15:08 khwilliamson

I'm happy to merge this, but will wait if @bram-perl wants to wait for other feedback.

(My experience is that this such feedback is unlikely for this area of the code)

khwilliamson avatar Aug 07 '22 15:08 khwilliamson

Some feedback on the change of the warning message is still welcome/needed.. That is: is the change acceptable? Or is it a bad idea and should the old message be preserved?

There are two changes in ouptut:

  • example 1:
    • old: perl: warning: Falling back to the standard locale ("C").
    • new: perl: warning: Falling back to a fallback locale (LANG) ("C").
  • example 2:
    • old: perl: warning: Falling back to a fallback locale ("en_US").
    • new: perl: warning: Falling back to a fallback locale (LANG) ("en_US").

bram-perl avatar Aug 11 '22 11:08 bram-perl

Some feedback on the change of the warning message is still welcome/needed.. That is: is the change acceptable? Or is it a bad idea and should the old message be preserved?

There are two changes in ouptut:

* example 1:
  
  * old: `perl: warning: Falling back to the standard locale ("C").`
  * new: `perl: warning: Falling back to a fallback locale (LANG) ("C").`

* example 2:
  
  * old: `perl: warning: Falling back to a fallback locale ("en_US").`
  * new: `perl: warning: Falling back to a fallback locale (LANG) ("en_US").`

The proposed new messages do seem awkward, as they contain redundant words. If you're "falling back" from some (presumably intended) locale to another locale, that second locale is a fallback locale by definition.

Based on past experience, changes in warnings or error messages should always be done cautiously, as people tend to write tests to detect them.

jkeenan avatar Aug 11 '22 12:08 jkeenan

The proposed new messages do seem awkward, as they contain redundant words. If you're "falling back" from some (presumably intended) locale to another locale, that second locale is a fallback locale by definition.

That wording has been in place since 2014. Sure it can be changed but that would change the message even more.

Based on past experience, changes in warnings or error messages should always be done cautiously, as people tend to write tests to detect them.

This message is shown when perl is started, not when some code is executed. (it's also completely unrelated to use warnings;, -w, ...) It is possible that people wrote tests for this but I think that is less likely.. (I could be wrong ofc) To test it they would need to do something like:

my $foo = qx/perl -e1 2>&1/;
if ($foo =~ m/......./) {
    ....
}

bram-perl avatar Aug 11 '22 12:08 bram-perl

I've updated the output so it behaves exactly the same as before; So there should be no visible change from these commits.

bram-perl avatar Aug 12 '22 20:08 bram-perl

I'll push whenever you've decided there's been a long enough time for suggested names, and change the first commit's message to not have the XXX

Done

bram-perl avatar Aug 15 '22 14:08 bram-perl