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 40
40
_PY_PATH_INSTALLED = False
41
41
42
42
43
+ try :
44
+ from os import fspath , PathLike
45
+ _OS_FSPATH_INSTALLED = True
46
+ except :
47
+ _OS_FSPATH_INSTALLED = False
48
+
49
+
43
50
if compat .PY3 :
44
51
from urllib .request import urlopen , pathname2url
45
52
_urlopen = urlopen
@@ -183,6 +190,10 @@ def _stringify_path(filepath_or_buffer):
183
190
-------
184
191
str_filepath_or_buffer : a the string version of the input path
185
192
"""
193
+ if _OS_FSPATH_INSTALLED and isinstance (filepath_or_buffer , PathLike ):
194
+ return fspath (filepath_or_buffer )
195
+ elif hasattr (filepath_or_buffer , "__fspath__" ):
196
+ return filepath_or_buffer .__fspath__ ()
186
197
if _PATHLIB_INSTALLED and isinstance (filepath_or_buffer , pathlib .Path ):
187
198
return text_type (filepath_or_buffer )
188
199
if _PY_PATH_INSTALLED and isinstance (filepath_or_buffer , LocalPath ):
You can’t perform that action at this time.
0 commit comments