| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
As of pybind/pybind11#5879, pybind11 will convert Python `int` to C `float`/`double`. For `std::variant`, pybind11 will attempt to convert arguments in the order of the type. So if `double` occurs earlier in the variant, then `int`/`long` will never be produced. By putting `int`/`long` before `double`, pybind11 will attempt that conversion first and we'll continue to produce our deprecation warning correctly. Fixes matplotlib#31495
|
Can we add this to the coding guidelines? (it's 100% the type of thing I'd forget when reviewing new C++ code) |
Sorry, something went wrong.
|
Confirmed that this works for me. Once we have this version of pybind11 in CI it will be very start failing hard so I'm not super worried about documenting it. |
Sorry, something went wrong.
|
or, if it goes in anyone's docs it should be pybind11's. |
Sorry, something went wrong.
|
Also, as a note, these variants should go away after branching 3.11 as they are deprecations to be removed in 3.12. So we hopefully would not have to worry about it for too long. |
Sorry, something went wrong.
|
Ah, am I being too excited about back-porting this to 3.10 as well then? |
Sorry, something went wrong.
|
No, it should go to 3.10 as well; the deprecations started in 3.10. |
Sorry, something went wrong.
…504-on-v3.10.x Backport PR #31504 on branch v3.10.x (Re-order variants to prioritize narrower types)
| Back | FazBrowse Home | New Git URL |
PR summary
As of pybind/pybind11#5879, pybind11 will convert Python int to C float/double. For std::variant, pybind11 will attempt to convert arguments in the order of the type.
So if double occurs earlier in the variant, then int/long will never be produced. By putting int/long before double, pybind11 will attempt that conversion first and we'll continue to produce our deprecation warning correctly.
Fixes #31495
AI Disclosure
None
PR checklist