File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 28
28
_PY_PATH_INSTALLED = False
29
29
30
30
31
+ try :
32
+ from os import fspath , PathLike
33
+ _OS_FSPATH_INSTALLED = True
34
+ except :
35
+ _OS_FSPATH_INSTALLED = False
36
+
37
+
31
38
if compat .PY3 :
32
39
from urllib .request import urlopen , pathname2url
33
40
_urlopen = urlopen
@@ -202,6 +209,10 @@ def _stringify_path(filepath_or_buffer):
202
209
-------
203
210
str_filepath_or_buffer : a the string version of the input path
204
211
"""
212
+ if _OS_FSPATH_INSTALLED and isinstance (filepath_or_buffer , PathLike ):
213
+ return fspath (filepath_or_buffer )
214
+ elif hasattr (filepath_or_buffer , "__fspath__" ):
215
+ return filepath_or_buffer .__fspath__ ()
205
216
if _PATHLIB_INSTALLED and isinstance (filepath_or_buffer , pathlib .Path ):
206
217
return text_type (filepath_or_buffer )
207
218
if _PY_PATH_INSTALLED and isinstance (filepath_or_buffer , LocalPath ):
You can’t perform that action at this time.
0 commit comments