-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
No fallback to __rmod__
magic method when __mod__
is not implemented
#1933
Comments
I've managed to solve this locally by changing Line 617 in 9d846c3
to py_binary_fallback_num_func!(
mod_rmod,
T,
PyNumberModProtocol::__mod__,
PyNumberRModProtocol::__rmod__
);
py_binary_num_func!(mod_, PyNumberModProtocol, T::__mod__);
py_binary_reversed_num_func!(rmod, PyNumberRModProtocol, T::__rmod__); and pyo3/pyo3-macros-backend/src/defs.rs Line 531 in d544c07
to SlotDef::new(&["__mod__", "__rmod__"], "Py_nb_remainder", "mod_rmod"),
SlotDef::new(&["__mod__"], "Py_nb_remainder", "mod_"),
SlotDef::new(&["__rmod__"], "Py_nb_remainder", "rmod"), if this is enough and there are no other potential places to fix -- I can open PR. |
__rmod__
magic method when __mod__
is not implemented__rmod__
magic method when __mod__
is not implemented
A PR would be very welcome! Note that in #1884 we're merging #[pyclass]
struct A;
#[pymethods]
impl A {
#[new]
fn new() -> A {
A {}
}
fn __mod__(&self, other: &PyAny) -> PyResult<PyObject> {
println!("A.__mod__ is called");
Ok(other.py().NotImplemented())
}
fn __rmod__(&self, other: &PyAny) -> PyResult<PyObject> {
println!("A.__rmod__ is called");
Ok(other.py().NotImplemented())
}
} |
2 tasks
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
🐛 Bug Reports
🌍 Environment
brew install python
)? Did you use a virtualenv?: yesrustc --version
): rustc 1.53.0 (53cb7b09b 2021-06-17)version = "0.x.y"
withgit = "https://github.com/PyO3/pyo3")?
: yes, the same💥 Reproducing
This repository has MCVE with README.
The text was updated successfully, but these errors were encountered: