Skip to content

Commit

Permalink
Add ParserSyntaxError as the cause of Invalid{Requirement/Marker}
Browse files Browse the repository at this point in the history
This ensures that these error tracebacks correctly describe the
causality between the two errors.
  • Loading branch information
pradyunsg committed Dec 7, 2022
1 parent 7930b73 commit 8cba45c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packaging/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def __init__(self, marker: str) -> None:
# ]
# ]
except ParserSyntaxError as e:
raise InvalidMarker(str(e))
raise InvalidMarker(str(e)) from e

def __str__(self) -> str:
return _format_marker(self._markers)
Expand Down
2 changes: 1 addition & 1 deletion packaging/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, requirement_string: str) -> None:
try:
parsed = parse_requirement(requirement_string)
except ParserSyntaxError as e:
raise InvalidRequirement(str(e))
raise InvalidRequirement(str(e)) from e

self.name: str = parsed.name
if parsed.url:
Expand Down

0 comments on commit 8cba45c

Please sign in to comment.