summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kowalik <steven@wedontsleep.org>2016-02-08 16:51:52 +1100
committerSteve Kowalik <steven@wedontsleep.org>2016-02-08 16:51:52 +1100
commitba5633b3c7b9317b87130a2ea671d8c008a673d6 (patch)
treebacfbb975bf64e62a4b3cf8131cd960c67efee45
parent7e1ca274068f946e5eb9cac457718ff37326d3a6 (diff)
downloadpython-setuptools-git-ba5633b3c7b9317b87130a2ea671d8c008a673d6.tar.gz
Switch back to SyntaxError for invalid markers, stops consumers having to import packaging themselves
-rw-r--r--pkg_resources/__init__.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 4e3a25ae..b0b04579 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -1395,7 +1395,7 @@ def invalid_marker(text):
"""
try:
evaluate_marker(text)
- except packaging.markers.InvalidMarker as e:
+ except SyntaxError as e:
e.filename = None
e.lineno = None
return e
@@ -1406,12 +1406,15 @@ def evaluate_marker(text, extra=None):
"""
Evaluate a PEP 508 environment marker.
Return a boolean indicating the marker result in this environment.
- Raise InvalidMarker if marker is invalid.
+ Raise SyntaxError if marker is invalid.
This implementation uses the 'pyparsing' module.
"""
marker = packaging.markers.Marker(text)
- return marker.evaluate()
+ try:
+ return marker.evaluate()
+ except packaging.marker.InvalidMarker as e:
+ raise SyntaxError(e)
class NullProvider: