[Python-Dev] Add transform() and untranform() methods

Serhiy Storchaka storchaka at gmail.com
Fri Nov 15 11:46:41 CET 2013

15.11.13 12:28, Steven D'Aprano написав(ла):
> One benefit is:
> import codecs
> codec = get_name_of_compression_codec()
> result = codecs.encode(data, codec)

And this is a hole in a security if you don't check codec name before 
calling a codec. See topic about utilizing zip-bombs via codecs machinery.

Also usually you need more than just uncompress binary data by Python 
name. You need map external compression name to internal Python codec 
name, you need configure decompressor object by specific options, 
perhaps you need different buffering strategies for different 
compression algorithms. See for example zipfile and tarfile sources.

More information about the Python-Dev mailing list