[issue12646] zlib.Decompress.decompress/flush do not raise any exceptions when given truncated input streams

Oleg Oshmyan report at bugs.python.org
Wed Jul 27 23:07:49 CEST 2011


Oleg Oshmyan <chortos at inbox.lv> added the comment:

I believe the attached patch fixes this problem, making zlib.Decompress.flush() raise the exception raised by zlib.decompress().

In the same patch, I also took the opportunity to correct a wrong comment in the implementation of flush() and change the error messages given by zlib.{De,C}ompress.flush() on {in,de}flateEnd() errors to the more end-user-friendly ones given in the same occasions by zlib.{de,}compress(). If this does not sound like a good thing to do, feel free (whoever ends up committing this) to remove these changes.

One uncomfortable issue I see with the patch is that zlib.Decompress.flush() now potentially gives an error message with Z_OK as the error code, but unless I misunderstand the comments in the real zlib’s zlib.h and that never happens (I was unable to produce a situation that would cause this), the only other options are faking another error code and setting an exception message whose format is different from all other exceptions raised by the zlib module.

----------
keywords: +patch
Added file: http://bugs.python.org/file22782/zlib.Decompress.flush.patch

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


More information about the Python-bugs-list mailing list