Skip to content

Commit 68d1086

Browse files
committed
readers: fix undefined FileNotFoundError and NotADirectoryError on Python 2
Signed-off-by: Filipe Laíns <[email protected]>
1 parent 0410296 commit 68d1086

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

importlib_resources/_compat.py

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ class ABC(object): # type: ignore
3636
FileNotFoundError = OSError # type: ignore
3737

3838

39+
try:
40+
NotADirectoryError = NotADirectoryError # type: ignore
41+
except NameError:
42+
NotADirectoryError = OSError # type: ignore
43+
44+
3945
try:
4046
from zipfile import Path as ZipPath # type: ignore
4147
except ImportError:

importlib_resources/readers.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from . import abc
66

77
from ._compat import Path, ZipPath
8+
from ._compat import FileNotFoundError, NotADirectoryError
89

910

1011
class FileReader(abc.TraversableResources):

0 commit comments

Comments
 (0)