mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Allow for arr KeyError
This commit is contained in:
parent
47691906df
commit
9b20276c45
|
@ -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)
|
||||
|
|
|
@ -2631,6 +2631,9 @@ def fromarray(obj, mode=None):
|
|||
if mode is None:
|
||||
try:
|
||||
typekey = (1, 1) + shape[2:], arr["typestr"]
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user