From: Robin Dunn Date: Sat, 19 Mar 2005 21:52:49 +0000 (+0000) Subject: Ensure that the encoding returned from locale.getdefaultlocale() is X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/0d5b83dc3ce36bc68cf61acb5945ef97c45db55a Ensure that the encoding returned from locale.getdefaultlocale() is valid, default to sys.getdefaultencoding() if not. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32915 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/src/_core_ex.py b/wxPython/src/_core_ex.py index f19ca7ecd7..caaf2a8058 100644 --- a/wxPython/src/_core_ex.py +++ b/wxPython/src/_core_ex.py @@ -40,14 +40,17 @@ if RELEASE_VERSION != _core_.RELEASE_VERSION: # http://www.alanwood.net/demos/charsetdiffs.html for differences # between the common latin/roman encodings. import locale +import codecs try: default = locale.getdefaultlocale()[1] -except ValueError: - default = "iso8859-1" + codecs.lookup(default) +except (ValueError, LookupError): + default = _sys.getdefaultencoding() if default: wx.SetDefaultPyEncoding(default) del default del locale +del codecs #----------------------------------------------------------------------------