diff --git a/python/src/_native.cpp b/python/src/_native.cpp index 7090451..bb30a51 100644 --- a/python/src/_native.cpp +++ b/python/src/_native.cpp @@ -103,9 +103,12 @@ PYBIND11_MODULE(_native, m) { // Downstream code может ловить либо конкретный subtype, либо CuframesError // как catch-all. - g_exc.base = py::exception(m, "CuframesError").attr("__class__"); - auto make_subexc = [&m](const char* name) { - return py::exception(m, name, g_exc.base.ptr()).attr("__class__"); + // py::exception(...) уже возвращает py::object на сам Python class. + // Не вызываем .attr("__class__") — иначе получим metaclass (type), + // а не сам exception class. + g_exc.base = py::exception(m, "CuframesError"); + auto make_subexc = [&m](const char* name) -> py::object { + return py::exception(m, name, g_exc.base.ptr()); }; g_exc.publisher_gone = make_subexc("CuframesPublisherGone"); g_exc.frame_timeout = make_subexc("CuframesFrameTimeout");