-
Notifications
You must be signed in to change notification settings - Fork 155
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
Float parsing fails with LANG=cs_CZ.UTF-8 and setlocale(LC_ALL, "") #2638
Comments
I guess JRuby is also affected since it runs on HotSpot, cc @enebo |
FWIW I found this way to find out what setlocale has been called with (on Linux, where LC_ALL is 6):
So I think that means for both cases on TruffleRuby all locale categories are set to en_GB, while on CRuby it's only LC_CTYPE, due to |
BTW it's not just
|
A workaround/solution seems to be to |
oracle/truffleruby#3513 is what I'm going to use to workaround for now in TruffleRuby. setlocale(LC_ALL, "C");
setlocale(LC_CTYPE, ""); which I think should be the same as CRuby doing just It is a workaround because this overwrites the locale for the whole process globally and might cause other things which rely on using the locale from the environment for all locale categories to fail. |
Dang, I figured since we had already validated it, it would work. I didn't realize it would disallow |
FWIW it seems glibc has it on Linux (looking at https://stackoverflow.com/questions/41794607/locale-invariant-string-processing-with-strtod-strtof-atof-printf mentions
I think double parsing is rather complicated, needs some large integers operations (not sure which ones), etc, so it's probably not so nice to vendor.
Right, that should work well with One last thought is if none of the above works well, maybe we could try on failure to replace the |
* ruby/prism#2638 got fixed so we don't need a C locale for Prism anymore.
* ruby/prism#2638 got fixed so we don't need a C locale for Prism anymore.
We had a report that truffleruby does not work with
LANG=cs_CZ.UTF-8
(which uses,
instead of.
as the decimal separator):It turns out this is caused by Prism not being able to parse Float literals when
LANG=cs_CZ.UTF-8
is set, andsetlocale(LC_ALL, "")
has been called.This is because Prism uses
strtod()
, which is locale-sensitive.It seems CRuby does
setlocale(LC_CTYPE, "")
(in main.c) and notsetlocale(LC_ALL, "")
, which means it doesn't reproduce as-is on CRuby.On TruffleRuby JVM, it seems HotSpot does
setlocale(LC_ALL, "")
, e.g. here.On TruffleRuby Native, we do the
setlocale(LC_ALL, "")
ourselves to callnl_langinfo(CODESET)
. Maybe we could change that one to LC_CTYPE instead, but it wouldn't solve the JVM case.And of course this would be a problem for any process which does
setlocale(LC_ALL, "")
before using Prism.The text was updated successfully, but these errors were encountered: