This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: External codecs no longer usable
Type: Stage:
Components: Unicode Versions: Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: lemburg Nosy List: ivilata, lemburg
Priority: normal Keywords:

Created on 2006-10-02 06:42 by ivilata, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg30107 - (view) Author: Ivan Vilata i Balaguer (ivilata) Date: 2006-10-02 06:42
Up to Python 2.5, external codec packages could be used
just by dropping them somewhere in the $PYTHONPATH, as
long as they provided a ``getregentry()`` function and
the normalised encoding name matched the name of the
package.  For instance, having a ``myencoding`` package
with a ``getregentry()`` function in it made possible
executing::

    >>> u'something'.encode('myencoding')

without even importing ``myencoding``.  It was the
``__import__(modname, ...)`` statement in
``encodings.search_function()`` which made this possible.

However, in Python 2.5 the previous statement was
changed to the absolute one ``__import('encodings.' +
modname, ...)``, which makes external codec packages no
longer reachable in the way described above.  Is this a
bug, or has this been made on purpose?  In the later
case, what do you recommend to use external codecs as
transparently as possible?  I now manually enter the
registry tuple/CodecInfo into the encodings cache, but
tampering with it doesn't seem right (and it also means
that some initialisation code must be explicitly run).

By the way, this bug may be related with #223642. 
Maybe it should be reopened.

Thank you very much!

(I know, I should have checked the betas and release
candidates in case this was a bug.  I didn't have the
time, sorry!)
msg30108 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2006-10-02 08:43
Logged In: YES 
user_id=38388

The encodings package codec search function was never
intended to be used by codecs other than the encodings package.

The 'encodings.' part for the module name was added to
prevent importing arbitrary modules as a result of looking
up a codec that's not defined in the encodings package which
could result in a security problem.

If you want to use your own codecs, please register a codec
search function with the codecs module first. It is
recommended to place the codecs into a package of its own -
again to prevent accidental import of non-codec modules.

See http://docs.python.org/lib/module-codecs.html for details.
History
Date User Action Args
2022-04-11 14:56:20adminsetgithub: 44065
2006-10-02 06:42:21ivilatacreate