diff --git a/PIL/Image.py b/PIL/Image.py index ce78bfa1b..b0b90a20b 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -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"): diff --git a/Tests/test_decompression_bomb.py b/Tests/test_decompression_bomb.py index 1b3873c1b..53c8bb5e6 100644 --- a/Tests/test_decompression_bomb.py +++ b/Tests/test_decompression_bomb.py @@ -31,7 +31,7 @@ def test_warning(): # Act / Assert assert_warning( - RuntimeWarning, + DecompressionBombWarning, lambda: Image.open(test_file)) # End of file