-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add object.{__lt__, __le__, __gt__, __gt__} #424
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -620,20 +620,28 @@ impl VirtualMachine { | |
}) | ||
} | ||
|
||
pub fn _lt(&mut self, a: &PyObjectRef, b: PyObjectRef) -> PyResult { | ||
self.call_method(a, "__lt__", vec![b]) | ||
pub fn _lt(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult { | ||
self.call_or_unsupported(a, b, "__lt__", "__gt__", |vm, a, b| { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The opposite of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, because Also from the python docs:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yes, you are right! Sorry for that! |
||
Err(vm.new_unsupported_operand_error(a, b, "<")) | ||
}) | ||
} | ||
|
||
pub fn _le(&mut self, a: &PyObjectRef, b: PyObjectRef) -> PyResult { | ||
self.call_method(a, "__le__", vec![b]) | ||
pub fn _le(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult { | ||
self.call_or_unsupported(a, b, "__le__", "__ge__", |vm, a, b| { | ||
Err(vm.new_unsupported_operand_error(a, b, "<=")) | ||
}) | ||
} | ||
|
||
pub fn _gt(&mut self, a: &PyObjectRef, b: PyObjectRef) -> PyResult { | ||
self.call_method(a, "__gt__", vec![b]) | ||
pub fn _gt(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult { | ||
self.call_or_unsupported(a, b, "__gt__", "__lt__", |vm, a, b| { | ||
Err(vm.new_unsupported_operand_error(a, b, ">")) | ||
}) | ||
} | ||
|
||
pub fn _ge(&mut self, a: &PyObjectRef, b: PyObjectRef) -> PyResult { | ||
self.call_method(a, "__ge__", vec![b]) | ||
pub fn _ge(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult { | ||
self.call_or_unsupported(a, b, "__ge__", "__le__", |vm, a, b| { | ||
Err(vm.new_unsupported_operand_error(a, b, ">=")) | ||
}) | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
float_{gt,ge,le}
need this change as wellThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks