Skip to content

Commit d2beaf3

Browse files
nandahkrishnaWillAyd
authored andcommitted
Remove py.path special handling from io.common (pandas-dev#26458)
1 parent f8ace5f commit d2beaf3

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

pandas/io/common.py

+2-15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import lzma
1010
import mmap
1111
import os
12+
import pathlib
1213
from urllib.error import URLError # noqa
1314
from urllib.parse import ( # noqa
1415
urlencode, urljoin, urlparse as parse_url, uses_netloc, uses_params,
@@ -115,24 +116,10 @@ def _stringify_path(filepath_or_buffer):
115116
Any other object is passed through unchanged, which includes bytes,
116117
strings, buffers, or anything else that's not even path-like.
117118
"""
118-
try:
119-
import pathlib
120-
_PATHLIB_INSTALLED = True
121-
except ImportError:
122-
_PATHLIB_INSTALLED = False
123-
124-
try:
125-
from py.path import local as LocalPath
126-
_PY_PATH_INSTALLED = True
127-
except ImportError:
128-
_PY_PATH_INSTALLED = False
129-
130119
if hasattr(filepath_or_buffer, '__fspath__'):
131120
return filepath_or_buffer.__fspath__()
132-
if _PATHLIB_INSTALLED and isinstance(filepath_or_buffer, pathlib.Path):
121+
elif isinstance(filepath_or_buffer, pathlib.Path):
133122
return str(filepath_or_buffer)
134-
if _PY_PATH_INSTALLED and isinstance(filepath_or_buffer, LocalPath):
135-
return filepath_or_buffer.strpath
136123
return _expand_user(filepath_or_buffer)
137124

138125

0 commit comments

Comments
 (0)