Skip to content

Commit 740e858

Browse files
committed
Revert "Remove ensure_is_path, no longer required after dropping Python 3.4." and "Drop support for Python 3.4."; Closes #104
This reverts commit 32127a5 and 760c9e1.
1 parent 86756e7 commit 740e858

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

importlib_metadata/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
ModuleNotFoundError,
2828
MetaPathFinder,
2929
email_message_from_string,
30+
ensure_is_path,
3031
PyPy_repr,
3132
)
3233
from importlib import import_module
@@ -219,7 +220,7 @@ def at(path):
219220
:param path: a string or path-like object
220221
:return: a concrete Distribution instance for the path
221222
"""
222-
return PathDistribution(pathlib.Path(path))
223+
return PathDistribution(ensure_is_path(path))
223224

224225
@staticmethod
225226
def _discover_resolvers():

importlib_metadata/_compat.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ def py2_message_from_string(text): # nocoverpy3
115115
PYPY_OPEN_BUG = getattr(sys, 'pypy_version_info', (9, 9, 9))[:3] <= (7, 1, 1)
116116

117117

118+
def ensure_is_path(ob):
119+
"""Construct a Path from ob even if it's already one.
120+
Specialized for Python 3.4.
121+
"""
122+
if (3,) < sys.version_info < (3, 5):
123+
ob = str(ob) # pragma: nocover
124+
return pathlib.Path(ob)
125+
126+
118127
class PyPy_repr:
119128
"""
120129
Override repr for EntryPoint objects on PyPy to avoid __iter__ access.

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ classifiers =
1515
Programming Language :: Python :: 2
1616

1717
[options]
18-
python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*
18+
python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
1919
setup_requires = setuptools-scm
2020
install_requires =
2121
zipp>=0.5
22-
pathlib2; python_version < '3'
22+
pathlib2; python_version=='3.4.*' or python_version < '3'
2323
contextlib2; python_version < '3'
2424
configparser>=3.5; python_version < '3'
2525
packages = find:

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ setenv =
3333
cov: COVERAGE_OPTIONS="-p"
3434
cov: COVERAGE_FILE={toxinidir}/.coverage
3535
py27: PYV=2
36-
py35,py36,py37,py38: PYV=3
36+
py34,py35,py36,py37,py38: PYV=3
3737
# workaround deprecation warnings in pip's vendored packages
3838
PYTHONWARNINGS=ignore:Using or importing the ABCs:DeprecationWarning:pip._vendor
3939
extras =

0 commit comments

Comments
 (0)