| 60 | } |
| 61 | |
| 62 | std::string object_to_string(const nb::object& obj, const std::string& fallback = "") { |
| 63 | if (!obj.is_valid() || obj.is_none()) |
| 64 | return fallback; |
| 65 | try { |
| 66 | return nb::cast<std::string>(obj); |
| 67 | } catch (...) { |
| 68 | return fallback; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | bool object_to_bool(const nb::object& obj, bool fallback = false) { |
| 73 | if (!obj.is_valid() || obj.is_none()) |
no test coverage detected