mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Merge pull request #4181 from pwohlhart/patch-1
Better error messaging in PIL.Image.fromarray
This commit is contained in:
commit
08cad40002
|
@ -52,3 +52,8 @@ class TestImageArray(PillowTestCase):
|
|||
self.assertEqual(test("RGB"), ("RGB", (128, 100), True))
|
||||
self.assertEqual(test("RGBA"), ("RGBA", (128, 100), True))
|
||||
self.assertEqual(test("RGBX"), ("RGBA", (128, 100), True))
|
||||
|
||||
# Test mode is None with no "typestr" in the array interface
|
||||
with self.assertRaises(TypeError):
|
||||
wrapped = Wrapper(test("L"), {"shape": (100, 128)})
|
||||
Image.fromarray(wrapped)
|
||||
|
|
|
@ -2570,9 +2570,12 @@ def fromarray(obj, mode=None):
|
|||
if mode is None:
|
||||
try:
|
||||
typekey = (1, 1) + shape[2:], arr["typestr"]
|
||||
mode, rawmode = _fromarray_typemap[typekey]
|
||||
except KeyError:
|
||||
raise TypeError("Cannot handle this data type")
|
||||
try:
|
||||
mode, rawmode = _fromarray_typemap[typekey]
|
||||
except KeyError:
|
||||
raise TypeError("Cannot handle this data type: %s, %s" % typekey)
|
||||
else:
|
||||
rawmode = mode
|
||||
if mode in ["1", "L", "I", "P", "F"]:
|
||||
|
|
Loading…
Reference in New Issue
Block a user