Fix ambiguous py::str(kwargs) overload on GCC#5946
Fix ambiguous py::str(kwargs) overload on GCC#5946Mohataseem89 wants to merge 6 commits intopybind:masterfrom
py::str(kwargs) overload on GCC#5946Conversation
|
|
||
| #endif | ||
|
|
||
| explicit str(const bytes &b); |
There was a problem hiding this comment.
Should the handle ctor below call release instead of ptr for safety?
include/pybind11/pytypes.h
Outdated
| # endif | ||
|
|
||
| // Avoid ambiguity when converting from kwargs (GCC) | ||
| explicit str(const kwargs &k) : str(static_cast<handle>(k)) {} |
There was a problem hiding this comment.
Yuck, it's weird because the handle goes through the raw_str function and steals THAT REFERENCE.
|
The intent here was to strictly mirror the existing |
|
|
|
Usually we do reviews only after all (or at least most) tests work. Currently basically everything is failing. |
|
A Cursor-generated solution (along with a test that actually reproduces the issue) is now under PR #5949 |
Fixes #5938
GCC reports an ambiguous overload when calling
py::str(kwargs)due tomultiple implicit conversions (handle/object)
this PR adds an explicit
str(const kwargs&)constructor forwarding tostr(handle), resolving the ambiguity while preserving existing behaviora small regression test is added to ensure
py::str(kwargs)remainsunambiguous across compilers