File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 17
17
from .filebasedimages import ImageFileError
18
18
from .imageclasses import all_image_classes
19
19
from .arrayproxy import is_proxy
20
- from .py3k import FileNotFoundError
20
+ from .py3k import FileNotFoundError , FileEmptyError
21
21
from .deprecated import deprecate_with_version
22
22
23
23
@@ -38,6 +38,10 @@ def load(filename, **kwargs):
38
38
'''
39
39
if not op .exists (filename ):
40
40
raise FileNotFoundError ("No such file: '%s'" % filename )
41
+
42
+ if op .getsize (filename ) <= 0 :
43
+ raise FileEmptyError ("Given file is empty: '%s'" % filename )
44
+
41
45
sniff = None
42
46
for image_klass in all_image_classes :
43
47
is_valid , sniff = image_klass .path_maybe_image (filename , sniff )
Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ class FileNotFoundError(IOError):
67
67
pass
68
68
69
69
70
+ class FileEmptyError (IOError ):
71
+ pass
72
+
73
+
70
74
def getexception ():
71
75
return sys .exc_info ()[1 ]
72
76
You can’t perform that action at this time.
0 commit comments