aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-07-03 12:14:42 -0400
committerGitHub <noreply@github.com>2020-07-03 12:14:42 -0400
commit78d2a3bfafd38112dc3c486cd478e4cee1f782ec (patch)
treee266940aea51aeae21717547b4ae715555bf2239
parent776fa9ffa471863f8d9502ca95872099394c506c (diff)
parent08e858804d6ef515b3bcea85e1b6e25a40487986 (diff)
downloadexternal_python_setuptools-78d2a3bfafd38112dc3c486cd478e4cee1f782ec.tar.gz
external_python_setuptools-78d2a3bfafd38112dc3c486cd478e4cee1f782ec.tar.bz2
external_python_setuptools-78d2a3bfafd38112dc3c486cd478e4cee1f782ec.zip
Merge pull request #2137 from pypa/debt/remove-RequirementParseError
Remove superfluous RequirementParseError
-rw-r--r--changelog.d/2137.change.rst1
-rw-r--r--pkg_resources/__init__.py14
2 files changed, 6 insertions, 9 deletions
diff --git a/changelog.d/2137.change.rst b/changelog.d/2137.change.rst
new file mode 100644
index 00000000..fb5f5075
--- /dev/null
+++ b/changelog.d/2137.change.rst
@@ -0,0 +1 @@
+Removed (private) pkg_resources.RequirementParseError, now replaced by packaging.requirements.InvalidRequirement. Kept the name for compatibility, but users should catch InvalidRequirement instead.
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 4ba49ec1..3f043049 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -3077,11 +3077,6 @@ def issue_warning(*args, **kw):
warnings.warn(stacklevel=level + 1, *args, **kw)
-class RequirementParseError(ValueError):
- def __str__(self):
- return ' '.join(self.args)
-
-
def parse_requirements(strs):
"""Yield ``Requirement`` objects for each specification in `strs`
@@ -3104,13 +3099,14 @@ def parse_requirements(strs):
yield Requirement(line)
+class RequirementParseError(packaging.requirements.InvalidRequirement):
+ "Compatibility wrapper for InvalidRequirement"
+
+
class Requirement(packaging.requirements.Requirement):
def __init__(self, requirement_string):
"""DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!"""
- try:
- super(Requirement, self).__init__(requirement_string)
- except packaging.requirements.InvalidRequirement as e:
- raise RequirementParseError(str(e))
+ super(Requirement, self).__init__(requirement_string)
self.unsafe_name = self.name
project_name = safe_name(self.name)
self.project_name, self.key = project_name, project_name.lower()