Skip to content

Commit f4a5e3a

Browse files
committed
Query for registration
1 parent 9d929cc commit f4a5e3a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

core/include/core/container_pybindings.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ register_g3vector(py::module_ &scope, std::string name, Args &&...args)
144144
// Register both regular std::vector version and G3Vector version,
145145
// with inheritance, so we can use both. Hide the std::vector version
146146
// with _ in the Python namespace to discourage accidental use.
147-
try {
147+
if (!py::detail::get_type_info(typeid(U))) {
148148
// base class may have been registered separately
149149
std::string base_name = std::string("_") + name + "BaseVector";
150150
register_vector<U>(scope, base_name);
151-
} catch (...) {}
151+
}
152152

153153
auto cls = register_vector<V, Bases..., U, G3FrameObject>(scope,
154154
name, std::forward<Args>(args)...);
@@ -285,7 +285,6 @@ register_map(py::module_ &scope, std::string name, Args &&...args)
285285
cls.def("__len__", [](const M &m) { return m.size(); });
286286

287287
py::implicitly_convertible<py::iterable, M>();
288-
py::implicitly_convertible<py::dict, M>();
289288

290289
return cls;
291290
}
@@ -311,11 +310,11 @@ register_g3map(py::module_ &scope, std::string name, Args &&...args)
311310
// Register both regular std::map version and G3Map version,
312311
// with inheritance, so we can use both. Hide the std::map version
313312
// with _ in the Python namespace to discourage accidental use.
314-
try {
313+
if (!py::detail::get_type_info(typeid(N))) {
315314
// base class may have been registered separately
316315
std::string base_name = std::string("_") + name + "BaseMap";
317316
register_map<N>(scope, base_name);
318-
} catch (...) {}
317+
}
319318

320319
auto cls = register_map<M, Bases..., N, G3FrameObject>(scope, name,
321320
std::forward<Args>(args)...);

0 commit comments

Comments
 (0)