From 02a1aa4ee878798518374c0b000002ab6559079a Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Fri, 5 Jan 2018 15:23:42 +0000 Subject: [PATCH] Typing: Note about fromarray and the buffer interface --- src/PIL/Image.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 2c306ba0d..6e30bb33c 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -2592,8 +2592,11 @@ def fromarray(obj, mode=None): else: obj_bytes = obj.tostring() - # UNDONE typing: can from buffer et al take an array_interface exporting object? - return frombuffer(mode, size, obj_bytes or obj, "raw", rawmode, 0, 1) + # Typing: At this point, obj should be an item exporting a buffer interface + # and obj_bytes, if it exists, is a bytes exporting a buffer interface. + # Unfortunately at this point, there's no protocol for the buffer interface + # and due to it's c-level implementation, I don't see how to make one. + return frombuffer(mode, size, obj_bytes or obj, "raw", rawmode, 0, 1) # type: ignore def fromqimage(im):