mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Use a custom subclass of RuntimeWarning for DecompressionBombWarning
This commit is contained in:
parent
195453679a
commit
46abe78b77
|
@ -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"):
|
||||
|
|
|
@ -31,7 +31,7 @@ def test_warning():
|
|||
|
||||
# Act / Assert
|
||||
assert_warning(
|
||||
RuntimeWarning,
|
||||
DecompressionBombWarning,
|
||||
lambda: Image.open(test_file))
|
||||
|
||||
# End of file
|
||||
|
|
Loading…
Reference in New Issue
Block a user