mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Use call_or_unsupported for operators.
This commit is contained in:
1 parent
328f81a28e
commit
561eb8ed4f
2 files changed
+7
-6
No files matched your search
@@ -5,4 +5,5 @@ __pycache__
|
||||
**/*.pytest_cache
|
||||
.*sw*
|
||||
.repl_history.txt
|
||||
.vscode
|
||||
wasm-pack.log
|
||||
+6
-6
@@ -549,27 +549,27 @@ impl VirtualMachine {
|
||||
}
|
||||
|
||||
pub fn _add(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
self.call_method(&a, "__add__", vec![b])
|
||||
self.call_or_unsupported(a, b, "__add__", "__radd__", "+")
|
||||
}
|
||||
|
||||
pub fn _mul(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
self.call_method(&a, "__mul__", vec![b])
|
||||
self.call_or_unsupported(a, b, "__mul__", "__rmul__", "*")
|
||||
}
|
||||
|
||||
pub fn _div(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
self.call_method(&a, "__truediv__", vec![b])
|
||||
self.call_or_unsupported(a, b, "__truediv__", "__truediv__", "/")
|
||||
}
|
||||
|
||||
pub fn _pow(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
self.call_method(&a, "__pow__", vec![b])
|
||||
self.call_or_unsupported(a, b, "__pow__", "__rpow__", "**")
|
||||
}
|
||||
|
||||
pub fn _modulo(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
self.call_method(&a, "__mod__", vec![b])
|
||||
self.call_or_unsupported(a, b, "__mod__", "__rmod__", "%")
|
||||
}
|
||||
|
||||
pub fn _xor(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
self.call_method(&a, "__xor__", vec![b])
|
||||
self.call_or_unsupported(a, b, "__xor__", "__rxor__", "^")
|
||||
}
|
||||
|
||||
pub fn _or(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
|
||||
Reference in new issue
Block a user