This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author fomcl@yahoo.com
Recipients eryksun, fomcl@yahoo.com, r.david.murray
Date 2015-02-17.10:35:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1424169352.42.0.943406287404.issue23425@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2015-02-17 10:35:52fomcl@yahoo.comsetrecipients: + fomcl@yahoo.com, r.david.murray, eryksun
2015-02-17 10:35:52fomcl@yahoo.comsetmessageid: <1424169352.42.0.943406287404.issue23425@psf.upfronthosting.co.za>
2015-02-17 10:35:52fomcl@yahoo.comlinkissue23425 messages
2015-02-17 10:35:52fomcl@yahoo.comcreate