Skip to content

Commit 8cba45c

Browse files
committed
Add ParserSyntaxError as the cause of Invalid{Requirement/Marker}
This ensures that these error tracebacks correctly describe the causality between the two errors.
1 parent 7930b73 commit 8cba45c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packaging/markers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def __init__(self, marker: str) -> None:
207207
# ]
208208
# ]
209209
except ParserSyntaxError as e:
210-
raise InvalidMarker(str(e))
210+
raise InvalidMarker(str(e)) from e
211211

212212
def __str__(self) -> str:
213213
return _format_marker(self._markers)

packaging/requirements.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, requirement_string: str) -> None:
3434
try:
3535
parsed = parse_requirement(requirement_string)
3636
except ParserSyntaxError as e:
37-
raise InvalidRequirement(str(e))
37+
raise InvalidRequirement(str(e)) from e
3838

3939
self.name: str = parsed.name
4040
if parsed.url:

0 commit comments

Comments
 (0)