Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,15 @@ def parse_version(version: str) -> "Optional[Tuple[int, ...]]":
except (TypeError, ValueError, AttributeError):
return None

if len(release_tuple) < 3:
# Pad out to three digits so that version comparison against a three-part
# tuple works as expected (e.g. (0, 1) should be >= than (0, 1, 0) when
# it comes to releases, but tuples don't compare that way).
if len(release_tuple) == 1:
release_tuple = (release_tuple[0], 0, 0)
elif len(release_tuple) == 2:
release_tuple = (release_tuple[0], release_tuple[1], 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Padding breaks two-part version equality

Low Severity

Padding parse_version so it always returns a three-tuple makes two-part results no longer equal two-part literals. The Sanic 21.9 workaround uses SanicIntegration.version == (21, 9) and will not run for a two-part 21.9 string, so the exception-path context exit is skipped.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cf58a84. Configure here.


return release_tuple


Expand Down
10 changes: 5 additions & 5 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,15 +535,15 @@ def test_match_regex_list(item, regex_list, expected_result):
["2.0.0b3", (2, 0, 0)],
["2.0.0b2", (2, 0, 0)],
["2.0.0b1", (2, 0, 0)],
["0.6beta3", (0, 6)],
["0.6beta2", (0, 6)],
["0.6beta1", (0, 6)],
["0.6beta3", (0, 6, 0)],
["0.6beta2", (0, 6, 0)],
["0.6beta1", (0, 6, 0)],
["0.4.2b", (0, 4, 2)],
["0.4.2a", (0, 4, 2)],
["0.0.1", (0, 0, 1)],
["0.0.0", (0, 0, 0)],
["1", (1,)],
["1.0", (1, 0)],
["1", (1, 0, 0)],
["1.0", (1, 0, 0)],
["1.0.0", (1, 0, 0)],
[" 1.0.0 ", (1, 0, 0)],
[" 1.0.0 ", (1, 0, 0)],
Expand Down
Loading