Message236129
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 |
|
Date |
User |
Action |
Args |
2015-02-17 10:35:52 | fomcl@yahoo.com | set | recipients:
+ fomcl@yahoo.com, r.david.murray, eryksun |
2015-02-17 10:35:52 | fomcl@yahoo.com | set | messageid: <1424169352.42.0.943406287404.issue23425@psf.upfronthosting.co.za> |
2015-02-17 10:35:52 | fomcl@yahoo.com | link | issue23425 messages |
2015-02-17 10:35:52 | fomcl@yahoo.com | create | |
|