[issue23528] Limit decompressed data when reading from GzipFile

Nikolaus Rath report at bugs.python.org
Thu Feb 26 22:10:02 CET 2015


Nikolaus Rath added the comment:

Especially now that this is only going to go into 3.5, I think it makes more sense to handle GzipFile, LZMAFile and BZ2File all in one go. Looking at the code, otherwise there's going to be a lot of duplication.

How about introducing a base class 'CompressedFile' that defines most of the logic that's currently in LZMAFile (including the max_size patch from issue 23529), and having {LZMA,BZ2,Gzip}File all inherit from that base?

BZ2File and LZMAFile would probably only need to define their own constructor to instantiate the proper compressor/decompressor object.

GzipFile would need to additionally overwrite read() and write() in order to handle the CRC and gzip header. But I think both methods could still be written to call super().read/write().

Did I miss something?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23528>
_______________________________________


More information about the Python-bugs-list mailing list