Message203036
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. |
|
Date |
User |
Action |
Args |
2013-11-16 12:30:39 | ncoghlan | set | recipients:
+ ncoghlan, lemburg, doerwalter, vstinner, ezio.melotti, serhiy.storchaka |
2013-11-16 12:30:39 | ncoghlan | set | messageid: <1384605039.56.0.360333589667.issue19619@psf.upfronthosting.co.za> |
2013-11-16 12:30:39 | ncoghlan | link | issue19619 messages |
2013-11-16 12:30:39 | ncoghlan | create | |
|