Skip to content

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented Dec 12, 2020

Helps #4926

The unaddressed part of that issue is that there is a chain of three ValueErrors raised by the following code.

>>> from PIL import Image
>>> img = Image.new('F', (200,100), 1.0)
>>> img.putalpha(Image.new('L', (200,100), 255))
Traceback (most recent call last):
  File "PIL/Image.py", line 1620, in putalpha
    self.im.setmode(mode)
ValueError: image has wrong mode

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "PIL/Image.py", line 1623, in putalpha
    im = self.im.convert(mode)
ValueError: conversion from F to LA not supported

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "PIL/Image.py", line 1630, in putalpha
    raise ValueError("illegal image mode") from e
ValueError: illegal image mode

This PR reduces it to two.

>>> from PIL import Image
>>> img = Image.new('F', (200,100), 1.0)
>>> img.putalpha(Image.new('L', (200,100), 255))
Traceback (most recent call last):
  File "PIL/Image.py", line 1620, in putalpha
ValueError: image has wrong mode

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "PIL/Image.py", line 1623, in putalpha
ValueError: conversion from F to LA not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants