[Python-Dev] Embedded python on Win2K, import failures (original) (raw)
M.-A. Lemburg mal@lemburg.com
Sat, 12 Apr 2003 13:49:11 +0200
- Previous message: [Python-Dev] Embedded python on Win2K, import failures
- Next message: [Python-Dev] Embedded python on Win2K, import failures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Martin v. L=F6wis wrote:
"M.-A. Lemburg" <mal@lemburg.com> writes: =20 =20
This looks like a modified site.py. Where did you get this from ? =20 Perhaps from the Python CVS?
Hmm, I don't have that in my CVS checkout... I guess a cleanup is due.
if sys.platform =3D=3D 'win32': import locale, codecs enc =3D locale.getdefaultlocale()[1] if enc.startswith('cp'): # "cp***" ? try: codecs.lookup(enc) except LookupError: import encodings encodings.cache[enc] =3D encodings.unknown encodings.aliases.aliases[enc] =3D 'mbcs'
That's the wrong way to do it.
This code should live in encodings/init.py, not site.py, and it should be done lazy, ie. Python startup time should not suffer from this in general, only when Unicode and cpXXX encodings are being requested and not found.
The codec machinery was carefully designed not to introduce extra overhead when not using Unicode in programs. The above approach pretty much kills this effort :-)
--=20 Marc-Andre Lemburg eGenix.com
Professional Python Software directly from the Source (#1, Apr 12 2003)
Python/Zope Products & Consulting ... http://www.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
EuroPython 2003, Charleroi, Belgium: 73 days left
- Previous message: [Python-Dev] Embedded python on Win2K, import failures
- Next message: [Python-Dev] Embedded python on Win2K, import failures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]