Skip to content

Remove py.path special handling from io.common #26458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
urlencode, urljoin, urlparse as parse_url, uses_netloc, uses_params,
uses_relative)
from urllib.request import pathname2url, urlopen
import warnings
import zipfile

from pandas.errors import ( # noqa
Expand Down Expand Up @@ -122,7 +123,7 @@ def _stringify_path(filepath_or_buffer):
_PATHLIB_INSTALLED = False

try:
from py.path import local as LocalPath
from py.path import local as LocalPath # Deprecated - 0.25.0
_PY_PATH_INSTALLED = True
except ImportError:
_PY_PATH_INSTALLED = False
Expand All @@ -132,6 +133,8 @@ def _stringify_path(filepath_or_buffer):
if _PATHLIB_INSTALLED and isinstance(filepath_or_buffer, pathlib.Path):
return str(filepath_or_buffer)
if _PY_PATH_INSTALLED and isinstance(filepath_or_buffer, LocalPath):
warnings.warn("py.path has been deprecated. Use pathlib instead.",
DeprecationWarning, stacklevel=2)
return filepath_or_buffer.strpath
return _expand_user(filepath_or_buffer)

Expand Down