Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d6b33a2

Browse files
authored
Re-order variants to prioritize narrower types (#31504)
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
1 parent e4f9152 commit d6b33a2

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/_backend_agg_wrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ PyRendererAgg_draw_path(RendererAgg *self,
5858
static void
5959
PyRendererAgg_draw_text_image(RendererAgg *self,
6060
py::array_t<agg::int8u, py::array::c_style | py::array::forcecast> image_obj,
61-
std::variant<double, int> vx,
62-
std::variant<double, int> vy,
61+
std::variant<int, double> vx,
62+
std::variant<int, double> vy,
6363
double angle,
6464
GCAgg &gc)
6565
{

src/ft2font_wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace py = pybind11;
1414
using namespace pybind11::literals;
1515

1616
template <typename T>
17-
using double_or_ = std::variant<double, T>;
17+
using double_or_ = std::variant<T, double>;
1818

1919
template <typename T>
2020
static T

0 commit comments

Comments
 (0)