albertjan added the comment:
Hi,
Thanks for your replies. Eryksun (nice to meet you here too!), your function
seems very useful, thank you very much. I had indeed already switched to your
'getrawlocale' approach.
Perhaps off-topic (because I have never seen this happen in Windows), but
locale.getlocale() sometimes returns (None, None), *even if*
locale.setlocale(locale.LC_ALL, "") has been called at the start of the
program. For some reason, LANG, LC_ALL and possible other vars are sometimes
not set correctly (I know this is not Python's fault, but...). Would it be a
good idea to have a 'failsafe' parameter in getlocale? Something like:
def safe_getlocale(failsafe=False):
current_locale = locale.getlocale()
if failsafe and current_locale[0] is None and not
sys.platform.startswith("win"):
os.environ["LANG"] = "en_US.UTF-8"
os.environ["LC_ALL"] = "en_US.UTF-8"
current_locale = locale.getlocale()
return current_locale
(sorry for squeezing this in the current issue!)
Albert-Jan
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23425>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com