-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
triageNew bug, unverifiedNew bug, unverified
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
3.0.1
Problem description
void test(const py::kwargs& kwargs)
{
auto s = py::str(kwargs);
}fails to compile with gcc with the following (condensed) error:
error: call of overloaded ‘str(const pybind11::kwargs&)’ is ambiguous
200 | auto s = py::str(kwargs);
| ^
note: candidate: ‘pybind11::str::str(pybind11::handle)’
1644 | explicit str(handle h) : object(raw_str(h.ptr()), stolen_t{}) {
| ^~~
note: candidate: ‘pybind11::str::str(const pybind11::bytes&)’
1774 | inline str::str(const bytes &b) {
| ^~~
note: candidate: ‘pybind11::str::str(const pybind11::object&)’
1596 | PYBIND11_OBJECT_CVT(str, object, PYBIND11_STR_CHECK_FUN, raw_str)
| ^~~~~~~~~~~~~~~~~~~
note: candidate: ‘pybind11::str::str(const pybind11::str&)’
1594 | class str : public object {
| ^~~
note: candidate: ‘pybind11::str::str(pybind11::str&&)’
This fails with at least g++-12 and g++-13 while it works with at least clang-17 and clang-18.
Any suggestion for a specific cast to work around the issue?
Reproducible example code
#include <pybind11/pybind11.h>
namespace py = pybind11;
void test(const py::kwargs& kwargs)
{
auto s = py::str(kwargs);
}
Is this a regression? Put the last known working version here if it is.
No response
Metadata
Metadata
Assignees
Labels
triageNew bug, unverifiedNew bug, unverified