Skip to content

Commit 820aa08

Browse files
committed
Handle missing FileNotFoundError
Might not really be necessary, since py27 triggers the ImportError always already, but better to be safe.
1 parent 9960b4c commit 820aa08

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

py/_path/common.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
# Moved from local.py.
1111
iswin32 = sys.platform == "win32" or (getattr(os, '_name', False) == 'nt')
1212

13+
try:
14+
# FileNotFoundError might happen in py34, and is not available with py27.
15+
import_errors = (ImportError, FileNotFoundError)
16+
except NameError:
17+
import_errors = (ImportError,)
18+
1319
try:
1420
from os import fspath
1521
except ImportError:
@@ -35,9 +41,7 @@ def fspath(path):
3541
raise
3642
try:
3743
import pathlib
38-
except ImportError:
39-
pass
40-
except FileNotFoundError: # Might happen in py34.
44+
except import_errors:
4145
pass
4246
else:
4347
if isinstance(path, pathlib.PurePath):

0 commit comments

Comments
 (0)