[IronPython] Standard encodings

Sanghyeon Seo sanxiyn at gmail.com
Wed Jul 19 10:47:06 CEST 2006


IronPython doesn't load standard encodings.

CPython implicitly tries to import encodings/__init__.py on first
codecs lookup, and this registers codecs search function which imports
encodings/<encoding_name>.py on demand. Any ImportError is ignored.

A simple workaround is to have "import encodings" in site.py. After
the import IronPython behaves the same.

Python 2.4.4c0 (#2, Jun 14 2006, 22:35:41)
[GCC 4.1.2 20060613 (prerelease) (Debian 4.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 'Python'.encode('rot13')
'Clguba'

IronPython 1.0.2391 (Beta) on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> 'Python'.encode('rot13')
Traceback (most recent call last):
LookupError: unknown encoding: rot13
>>> import encodings
>>> 'Python'.encode('rot13')
'Clguba'

Seo Sanghyeon



More information about the Ironpython-users mailing list