value under the 'invalid_image' key of the self.error_messages dictionary and code set to a string 'invalid_image', and third element of the return value of the function sys.exc_info. if f has an attribute 'seek' and if f.seek is an callable object,
if hasattr ( f , 'seek' ) and callable ( f . seek ) :