-
Notifications
You must be signed in to change notification settings - Fork 10
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
Change default locale to an UTF-8 one #26
Comments
@jitakirin Which is the base image that are you using? I think the easiest way to work around that is to use the PYTHONIOENCODING=UTF-8 environment variable, which will ensure that UTF-8 is used regardless of what python guesses from the system. In the official library the python images make use of the
In your dockerfile or include it in the tool you use to create any derived image. Also, I am a bit concerned about setting some kind of a default locale in a container, since distros are starting to make use of systemd tools in order to set locales and, at least at the moment, we don't expect to have systemd running within the container (i.e. localectl command won't work in our base images). Hope it helps |
I believe this is related to this known Python issue. Not sure if there's much we can really do (it's not clear how we should set the locale and whether/how it should be inherited from the host it's running on). |
@davidcassany Sorry, I should've mentioned, I use @cyphar I think you are spot on, it appears to be because python detects the encoding as ascii from the locale (or lack thereof), i.e.: $ python3 -c "import sys; print(sys.getfilesystemencoding())"
ascii Setting One thing I'm still wondering about - with PEP 538 implemented, python would indeed attempt to alleviate this, but I'm not sure if it would work with the current tumbleweed image. IIUC Python 3.7 will essentially attempt to set $ LC_CTYPE=C.UTF-8 python3 -c "import sys; print(sys.getfilesystemencoding())"
utf-8
$ LC_CTYPE=C.UTF-8 python3 -c 'print("\342\206\227")'
â This doesn't work in base tumbleweed as it appears $ LC_CTYPE=C.UTF-8 python3 -c "import sys; print(sys.getfilesystemencoding())"
ascii
$ LC_CTYPE=C.UTF-8 python3 -c 'print("\342\206\227")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) and: LC_CTYPE=C.UTF-8 locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=
LC_CTYPE=C.UTF-8
LC_NUMERIC="POSIX"
...
LC_ALL= So I suppose one final question is, shouldn't |
@jitakirin we are currently discussing it, this is not obvious since this C.UTF-8 (and all others) locale comes from |
I came across #12 and I understand why additional locales are not installed, however..
Would it be possible to change the default locale from
POSIX
toC.UTF-8
? The current default causes problems with python programs, for example:when run will produce:
The text was updated successfully, but these errors were encountered: