[Python-checkins] python/dist/src/Lib site.py,1.47,1.48
loewis@users.sourceforge.net
loewis@users.sourceforge.net
Mon, 03 Mar 2003 01:34:05 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv23190
Modified Files:
site.py
Log Message:
Patch #671666: Alias ANSI code page to "mbcs".
Index: site.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** site.py 30 Dec 2002 22:08:02 -0000 1.47
--- site.py 3 Mar 2003 09:34:01 -0000 1.48
***************
*** 283,286 ****
--- 283,302 ----
+ # On Windows, some default encodings are not provided
+ # by Python (e.g. "cp932" in Japanese locale), while they
+ # are always available as "mbcs" in each locale.
+ # Make them usable by aliasing to "mbcs" in such a case.
+
+ if sys.platform == 'win32':
+ import locale, codecs
+ enc = locale.getdefaultlocale()[1]
+ if enc.startswith('cp'): # "cp***" ?
+ try:
+ codecs.lookup(enc)
+ except LookupError:
+ import encodings
+ encodings._cache[enc] = encodings._unknown
+ encodings.aliases.aliases[enc] = 'mbcs'
+
# Set the string encoding used by the Unicode implementation. The
# default is 'ascii', but if you're willing to experiment, you can