-
Notifications
You must be signed in to change notification settings - Fork 577
Strange interaction with locale and late loading Encode module #21746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's not clear that that
|
@jkeenan That looks as expected to me. The locale system comes with various categories that can be configured individually, but they don't have to be: By unsetting everything else, we make sure that the value specified in |
On 12/22/23 12:12, mauke wrote:
@jkeenan <https://github.com/jkeenan> That looks as expected to me. The
locale system comes with various categories that can be configured
individually, but they don't have to be: |LANG| is the fallback value
used for all of them; |LC_foo| can be set to override a specific
category |foo| individually; and |LC_ALL| overrides everything else.
By unsetting everything else, we make sure that the value specified in
|LANG| is used for every category. (The output of |locale| reflects this.)
Thanks for that clarification.
|
Bisection with the following invocation:
... points to this commit:
@khwilliamson, can you take a look? Thanks. |
One of the notorious problems with the
The example provided by the OP in this ticket imports those hundreds of symbols into the namespace.
However, when I import only the
Let's also try an empty argument list.
(I'm using the |
In that case try &POSIX::LC_ALL to get the correct constant! |
This fixes GH Perl#21746 Perl keeps the LC_NUMERIC category in a locale where the radix character is a dot, regardless of what the user has requested. This is because much XS code has been written with the dot assumption. When the user's actual radix character is desired, the locale is briefly toggled to that one for the duration of the operation. When the user changes the LC_NUMERIC locale, the new one is noted, but the attempted change is otherwise ignored unless its radix is a dot. The new one will be briefly toggled into when appropriate. The blamed commit contains a logic error commit 818cdb7 Author: Karl Williamson <[email protected]> AuthorDate: Sun Apr 11 05:57:07 2021 -0600 Commit: Karl Williamson <[email protected]> CommitDate: Thu Sep 1 09:02:04 2022 -0600 locale.c: Skip code if will be a no-op It decided it was a no-op if the new locale that the user is changing to is the same as the previous locale. But it didn't consider that what actually happens is that the new locale does actually get changed, and this code is supposed to make sure that, before returning control to the user, that a dot radix locale is in effect. If the new locale is a dot radix locale, then no harm is done by skipping the code, but otherwise things can go wrong. I am chagrined that I made this logic error without noticing before it got pushed, and am surprised that it took this long for the error to surrface. There must be something else intervening to make this not a problem in most circumstances, but I haven't analyzed what it might be. The details as to why it happened in this test case are pretty obscure. The locale in effect is looking for a comma radix, but what is being checked for is a Perl version number, like 5.0936. When converting that to a floating point number, the dot is not recognized, and only the initial '5' is found. The failing code in a module has different actions depending on the current perl version it is being called from, and the conditional got the answer wrong because 5 is less than 5.0936, whereas the actual version is above that. So it did the wrong thing and caused an error.
@ailin-nemui, does #21786 address your problem? |
This fixes GH #21746 Perl keeps the LC_NUMERIC category in a locale where the radix character is a dot, regardless of what the user has requested. This is because much XS code has been written with the dot assumption. When the user's actual radix character is desired, the locale is briefly toggled to that one for the duration of the operation. When the user changes the LC_NUMERIC locale, the new one is noted, but the attempted change is otherwise ignored unless its radix is a dot. The new one will be briefly toggled into when appropriate. The blamed commit contains a logic error commit 818cdb7 Author: Karl Williamson <[email protected]> AuthorDate: Sun Apr 11 05:57:07 2021 -0600 Commit: Karl Williamson <[email protected]> CommitDate: Thu Sep 1 09:02:04 2022 -0600 locale.c: Skip code if will be a no-op It decided it was a no-op if the new locale that the user is changing to is the same as the previous locale. But it didn't consider that what actually happens is that the new locale does actually get changed, and this code is supposed to make sure that, before returning control to the user, that a dot radix locale is in effect. If the new locale is a dot radix locale, then no harm is done by skipping the code, but otherwise things can go wrong. I am chagrined that I made this logic error without noticing before it got pushed, and am surprised that it took this long for the error to surrface. There must be something else intervening to make this not a problem in most circumstances, but I haven't analyzed what it might be. The details as to why it happened in this test case are pretty obscure. The locale in effect is looking for a comma radix, but what is being checked for is a Perl version number, like 5.0936. When converting that to a floating point number, the dot is not recognized, and only the initial '5' is found. The failing code in a module has different actions depending on the current perl version it is being called from, and the conditional got the answer wrong because 5 is less than 5.0936, whereas the actual version is above that. So it did the wrong thing and caused an error.
thanks |
This fixes GH Perl#21746 Perl keeps the LC_NUMERIC category in a locale where the radix character is a dot, regardless of what the user has requested. This is because much XS code has been written with the dot assumption. When the user's actual radix character is desired, the locale is briefly toggled to that one for the duration of the operation. When the user changes the LC_NUMERIC locale, the new one is noted, but the attempted change is otherwise ignored unless its radix is a dot. The new one will be briefly toggled into when appropriate. The blamed commit contains a logic error commit 818cdb7 Author: Karl Williamson <[email protected]> AuthorDate: Sun Apr 11 05:57:07 2021 -0600 Commit: Karl Williamson <[email protected]> CommitDate: Thu Sep 1 09:02:04 2022 -0600 locale.c: Skip code if will be a no-op It decided it was a no-op if the new locale that the user is changing to is the same as the previous locale. But it didn't consider that what actually happens is that the new locale does actually get changed, and this code is supposed to make sure that, before returning control to the user, that a dot radix locale is in effect. If the new locale is a dot radix locale, then no harm is done by skipping the code, but otherwise things can go wrong. I am chagrined that I made this logic error without noticing before it got pushed, and am surprised that it took this long for the error to surrface. There must be something else intervening to make this not a problem in most circumstances, but I haven't analyzed what it might be. The details as to why it happened in this test case are pretty obscure. The locale in effect is looking for a comma radix, but what is being checked for is a Perl version number, like 5.0936. When converting that to a floating point number, the dot is not recognized, and only the initial '5' is found. The failing code in a module has different actions depending on the current perl version it is being called from, and the conditional got the answer wrong because 5 is less than 5.0936, whereas the actual version is above that. So it did the wrong thing and caused an error.
This fixes GH #21746 Perl keeps the LC_NUMERIC category in a locale where the radix character is a dot, regardless of what the user has requested. This is because much XS code has been written with the dot assumption. When the user's actual radix character is desired, the locale is briefly toggled to that one for the duration of the operation. When the user changes the LC_NUMERIC locale, the new one is noted, but the attempted change is otherwise ignored unless its radix is a dot. The new one will be briefly toggled into when appropriate. The blamed commit contains a logic error commit 818cdb7 Author: Karl Williamson <[email protected]> AuthorDate: Sun Apr 11 05:57:07 2021 -0600 Commit: Karl Williamson <[email protected]> CommitDate: Thu Sep 1 09:02:04 2022 -0600 locale.c: Skip code if will be a no-op It decided it was a no-op if the new locale that the user is changing to is the same as the previous locale. But it didn't consider that what actually happens is that the new locale does actually get changed, and this code is supposed to make sure that, before returning control to the user, that a dot radix locale is in effect. If the new locale is a dot radix locale, then no harm is done by skipping the code, but otherwise things can go wrong. I am chagrined that I made this logic error without noticing before it got pushed, and am surprised that it took this long for the error to surrface. There must be something else intervening to make this not a problem in most circumstances, but I haven't analyzed what it might be. The details as to why it happened in this test case are pretty obscure. The locale in effect is looking for a comma radix, but what is being checked for is a Perl version number, like 5.0936. When converting that to a floating point number, the dot is not recognized, and only the initial '5' is found. The failing code in a module has different actions depending on the current perl version it is being called from, and the conditional got the answer wrong because 5 is less than 5.0936, whereas the actual version is above that. So it did the wrong thing and caused an error.
Module:
Description
Trying to
use Encode
afterPOSIX::setlocale
has been changed to Polish, causes the following error:Steps to Reproduce
(in case you have any of that set)
you can also get the same error with:
Expected behavior
use Encode
should not crash depending on the localePerl configuration
The text was updated successfully, but these errors were encountered: