Skip to content

Commit

Permalink
Handle missing FileNotFoundError
Browse files Browse the repository at this point in the history
Might not really be necessary, since py27 triggers the ImportError
always already, but better to be safe.
  • Loading branch information
blueyed committed Feb 22, 2019
1 parent 2edd802 commit 74e8a71
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions py/_path/common.py
Expand Up @@ -10,6 +10,12 @@
# Moved from local.py.
iswin32 = sys.platform == "win32" or (getattr(os, '_name', False) == 'nt')

try:
# FileNotFoundError might happen in py34, and is not available with py27.
import_errors = (ImportError, FileNotFoundError)
except NameError:
import_errors = (ImportError,)

try:
from os import fspath
except ImportError:
Expand All @@ -35,9 +41,7 @@ def fspath(path):
raise
try:
import pathlib
except ImportError:
pass
except FileNotFoundError: # Might happen in py34.
except import_errors:
pass
else:
if isinstance(path, pathlib.PurePath):
Expand Down

0 comments on commit 74e8a71

Please sign in to comment.