[ python-Bugs-1569084 ] External codecs no longer usable
SourceForge.net
noreply at sourceforge.net
Mon Oct 2 10:43:54 CEST 2006
Bugs item #1569084, was opened at 2006-10-02 08:42
Message generated for change (Comment added) made by lemburg
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1569084&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Unicode
Group: Python 2.5
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Ivan Vilata i Balaguer (ivilata)
Assigned to: M.-A. Lemburg (lemburg)
Summary: External codecs no longer usable
Initial Comment:
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!)
----------------------------------------------------------------------
>Comment By: M.-A. Lemburg (lemburg)
Date: 2006-10-02 10:43
Message:
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1569084&group_id=5470
More information about the Python-bugs-list
mailing list