Use a custom subclass of RuntimeWarning for DecompressionBombWarning

This commit is contained in:
hugovk 2014-06-23 10:53:08 +03:00
parent 195453679a
commit 46abe78b77
2 changed files with 5 additions and 2 deletions

View File

@ -31,6 +31,9 @@ from PIL import VERSION, PILLOW_VERSION, _plugins
import warnings
class DecompressionBombWarning(RuntimeWarning):
pass
class _imaging_not_installed:
# module placeholder
def __getattr__(self, id):
@ -2187,7 +2190,7 @@ def _decompression_bomb_check(size):
"Image size (%d pixels) exceeds limit of %d pixels, "
"could be decompression bomb DOS attack." %
(pixels, MAX_IMAGE_PIXELS),
RuntimeWarning)
DecompressionBombWarning)
def open(fp, mode="r"):

View File

@ -31,7 +31,7 @@ def test_warning():
# Act / Assert
assert_warning(
RuntimeWarning,
DecompressionBombWarning,
lambda: Image.open(test_file))
# End of file