I guess that code
lc, encoding = locale.getdefaultlocale()
should be replaced with something along the lines
lc = locale.getlocale(locale.LC_MESSAGES)
encoding = locale.getpreferredencoding()
Note that locale.getlocale() should not be called before the process has called locale.setlocale(locale.LC_ALL, "") [which, I think, is true in this case]. If encoding is not needed, the latter call may be obviously dropped.
I guess that code getdefaultlocal e() getlocale( locale. LC_MESSAGES) getpreferredenc oding() setlocale( locale. LC_ALL, "") [which, I think, is true in this case]. If encoding is not needed, the latter call may be obviously dropped.
lc, encoding = locale.
should be replaced with something along the lines
lc = locale.
encoding = locale.
Note that locale.getlocale() should not be called before the process has called locale.