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.

Author ncoghlan
Recipients doerwalter, ezio.melotti, lemburg, ncoghlan, serhiy.storchaka, vstinner
Date 2013-11-16.12:30:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1384605039.56.0.360333589667.issue19619@psf.upfronthosting.co.za>
In-reply-to
Content
Note that users can completely blacklist any codec that hasn't been imported yet by preventing imports of that codec definition:

>>> import sys, encodings
>>> blocked_codecs = "bz2_codec", "zlib_codec"
>>> for name in blocked_codecs:
...     sys.modules["encodings." + name] = None
...     setattr(encodings, name, None)
... 
>>> b"payload".decode("bz2_codec")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
LookupError: unknown encoding: bz2_codec
>>> b"payload".decode("zlib_codec")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
LookupError: unknown encoding: zlib_codec

Add in an "encodings._cache.clear()" and you can also block the use of previously used codecs.

Regardless of what else we do, we should document this so that users know how to do it.

This means the case we're handling in this issue is just the one where we want to block a codec from the builtin method APIs, while still allowing it in the codecs module APIs.
History
Date User Action Args
2013-11-16 12:30:39ncoghlansetrecipients: + ncoghlan, lemburg, doerwalter, vstinner, ezio.melotti, serhiy.storchaka
2013-11-16 12:30:39ncoghlansetmessageid: <1384605039.56.0.360333589667.issue19619@psf.upfronthosting.co.za>
2013-11-16 12:30:39ncoghlanlinkissue19619 messages
2013-11-16 12:30:39ncoghlancreate