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
This commit is contained in:
@@ -40,14 +40,17 @@ if RELEASE_VERSION != _core_.RELEASE_VERSION:
|
|||||||
# http://www.alanwood.net/demos/charsetdiffs.html for differences
|
# http://www.alanwood.net/demos/charsetdiffs.html for differences
|
||||||
# between the common latin/roman encodings.
|
# between the common latin/roman encodings.
|
||||||
import locale
|
import locale
|
||||||
|
import codecs
|
||||||
try:
|
try:
|
||||||
default = locale.getdefaultlocale()[1]
|
default = locale.getdefaultlocale()[1]
|
||||||
except ValueError:
|
codecs.lookup(default)
|
||||||
default = "iso8859-1"
|
except (ValueError, LookupError):
|
||||||
|
default = _sys.getdefaultencoding()
|
||||||
if default:
|
if default:
|
||||||
wx.SetDefaultPyEncoding(default)
|
wx.SetDefaultPyEncoding(default)
|
||||||
del default
|
del default
|
||||||
del locale
|
del locale
|
||||||
|
del codecs
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user