Remove deprecated code due for removal in Pillow 4.2 (per PR #2010)

This commit is contained in:
hugovk 2017-05-27 23:20:03 +03:00
parent 4c3107c940
commit e4d6223c94
3 changed files with 4 additions and 17 deletions

View File

@ -554,7 +554,6 @@ RAWMODE = {
"1": "L",
"L": "L",
"RGB": "RGB",
"RGBA": "RGB",
"RGBX": "RGB",
"CMYK": "CMYK;I", # assume adobe conventions
"YCbCr": "YCbCr",
@ -603,14 +602,6 @@ def _save(im, fp, filename):
except KeyError:
raise IOError("cannot write mode %s as JPEG" % im.mode)
if im.mode == 'RGBA':
warnings.warn(
'You are saving RGBA image as JPEG. The alpha channel will be '
'discarded. This conversion is deprecated and will be disabled '
'in Pillow 3.7. Please, convert the image to RGB explicitly.',
DeprecationWarning
)
info = im.encoderinfo
dpi = [int(round(x)) for x in info.get("dpi", (0, 0))]

View File

@ -476,17 +476,11 @@ class TestFileJpeg(PillowTestCase):
img.save(out, "JPEG")
def test_save_wrong_modes(self):
out = BytesIO()
for mode in ['LA', 'La', 'RGBa', 'P']:
img = Image.new(mode, (20, 20))
self.assertRaises(IOError, img.save, out, "JPEG")
def test_save_modes_with_warnings(self):
# ref https://github.com/python-pillow/Pillow/issues/2005
out = BytesIO()
for mode in ['RGBA']:
for mode in ['LA', 'La', 'RGBA', 'RGBa', 'P']:
img = Image.new(mode, (20, 20))
self.assert_warning(DeprecationWarning, img.save, out, "JPEG")
self.assertRaises(IOError, img.save, out, "JPEG")
def test_save_tiff_with_dpi(self):
# Arrange

View File

@ -7,3 +7,5 @@ Removed Deprecated Items
Several deprecated items have been removed.
* The methods :py:meth:`PIL.ImageWin.Dib.fromstring` and :py:meth:`PIL.ImageWin.Dib.tostring` have been removed.
* Before Pillow 4.2.0, attempting to save an RGBA image as JPEG would discard the alpha channel. From Pillow 3.4.0, a deprecation warning was shown. From Pillow 4.2.0, the deprecation warning is removed and an :py:exc:`IOError` is raised.