From 0d5b83dc3ce36bc68cf61acb5945ef97c45db55a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 19 Mar 2005 21:52:49 +0000 Subject: [PATCH] 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 --- wxPython/src/_core_ex.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 #---------------------------------------------------------------------------- -- 2.50.0