-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix ambiguous py::str(kwargs) overload on GCC
#5946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| #endif | ||
|
|
||
| explicit str(const bytes &b); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
|
thanks for the clarification agreed. I will take a closer look at the CI failures and update the PR accordingly before requesting further review. |
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