diff --git a/PIL/Image.py b/PIL/Image.py index 36060c759..99acb78fa 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -92,7 +92,7 @@ except ImportError: from PIL import ImageMode from PIL._binary import i8, o8 -from PIL._util import isPath, isStringType +from PIL._util import isPath, isStringType, deferred_error import os, sys @@ -513,7 +513,10 @@ class Image: if Image.DEBUG: print ("Error closing: %s" %msg) - self.im = None + # Instead of simply setting to None, we're setting up a + # deferred error that will better explain that the core image + # object is gone. + self.im = deferred_error(ValueError("Operation on closed image")) def _copy(self):