Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent crash when comparing ill-typed numeric types. #2949

Merged
merged 1 commit into from
Oct 23, 2024
Merged
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
10 changes: 8 additions & 2 deletions rdflib/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,9 +1107,15 @@ def __gt__(self, other: Any) -> bool:
if other is None:
return True # Everything is greater than None
if isinstance(other, Literal):
# Fast path for comapring numeric literals
# that are not ill-typed and don't have a None value
if (
self.datatype in _NUMERIC_LITERAL_TYPES
and other.datatype in _NUMERIC_LITERAL_TYPES
(
self.datatype in _NUMERIC_LITERAL_TYPES
and other.datatype in _NUMERIC_LITERAL_TYPES
)
and ((not self.ill_typed) and (not other.ill_typed))
and (self.value is not None and other.value is not None)
):
return self.value > other.value

Expand Down
Loading