pyo3 icon indicating copy to clipboard operation
pyo3 copied to clipboard

`#[pyo3(from_py_with)]` is ignored in dunder methods (`__eq__`, etc.)

Open wyfo opened this issue 10 months ago • 1 comments

Everything is in the title. Currently, #[pyo3(from_py_with)] is just ignored for dunder methods like __eq__ in my case, you can even write fake function name, it has not effect at all.

I've started looking at the code, it seems that dunder methods use a completely different code for generation, so fixing this issue seems not so trivial. Waiting for the solution, this behavior should at least be documented, to avoid the surprise for the users.

wyfo avatar Apr 24 '24 12:04 wyfo

I think it makes sense to allow [pyo3(from_py_with= ...)] there, given that extracting types directly is already allowed. I implemented a fix in #4117, which should now handle them correctly.

Icxolu avatar Apr 24 '24 20:04 Icxolu