Closed
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?
Problem description
The attached example code binds two map types: std::map<uint16_t, uint16_t>
and std::map<uint32_t, uint16_t>
.
With recent pybind11 this fails when importing with:
ImportError: generic_type: cannot initialize type "KeysView[int]": an object with that name is already defined
Looking at the relevant code:
pybind11/include/pybind11/stl_bind.h
Line 733 in 3cc7e42
checks whether a matching key typeid has been wrapped already; but in this case two different typeids have the same string name in pybind11.
This is breaking a project that happens to use this; if there's a workaround other than unifying the map key types that fixes things with recent pybind11 releases that would also be useful to know.
Thanks for your help!
Reproducible example code
#include <pybind11/pybind11.h>
#include <pybind11/stl_bind.h>
#include <map>
namespace py = pybind11;
PYBIND11_MODULE(python_example, m) {
py::bind_map<std::map<uint16_t, uint16_t>>(m, "u16u16map");
py::bind_map<std::map<uint32_t, uint16_t>>(m, "u32u16map");
}
Is this a regression? Put the last known working version here if it is.
Believe this was broken by 9db9880. 2.10.0 was known working.