mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-17 10:44:45 +03:00
Merge 48e12e04de
into f4b81d6b7e
This commit is contained in:
commit
157536a75d
|
@ -2033,6 +2033,8 @@ def new(mode, size, color=0):
|
||||||
:returns: An :py:class:`~PIL.Image.Image` object.
|
:returns: An :py:class:`~PIL.Image.Image` object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_decompression_bomb_check(size)
|
||||||
|
|
||||||
if color is None:
|
if color is None:
|
||||||
# don't initialize
|
# don't initialize
|
||||||
return Image()._new(core.new(mode, size))
|
return Image()._new(core.new(mode, size))
|
||||||
|
|
|
@ -39,5 +39,17 @@ class TestDecompressionBomb(PillowTestCase):
|
||||||
Image.DecompressionBombWarning,
|
Image.DecompressionBombWarning,
|
||||||
lambda: Image.open(TEST_FILE))
|
lambda: Image.open(TEST_FILE))
|
||||||
|
|
||||||
|
def test_image_new(self):
|
||||||
|
# Arrange
|
||||||
|
# Set limit to a low, easily testable value
|
||||||
|
Image.MAX_IMAGE_PIXELS = 10
|
||||||
|
self.assertEqual(Image.MAX_IMAGE_PIXELS, 10)
|
||||||
|
|
||||||
|
# Act / Assert
|
||||||
|
self.assert_warning(
|
||||||
|
Image.DecompressionBombWarning,
|
||||||
|
lambda: Image.new('L', (100, 100), 0))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user