| 112 | } |
| 113 | |
| 114 | PyObject* safe_import(PyObject* module, std::string fname) { |
| 115 | PyObject* fn = PyObject_GetAttrString(module, fname.c_str()); |
| 116 | |
| 117 | if (!fn) |
| 118 | throw std::runtime_error(std::string("Couldn't find required function: ") + fname); |
| 119 | |
| 120 | if (!PyFunction_Check(fn)) |
| 121 | throw std::runtime_error(fname + std::string(" is unexpectedly not a PyFunction.")); |
| 122 | |
| 123 | return fn; |
| 124 | } |
| 125 | |
| 126 | private: |
| 127 |
nothing calls this directly
no outgoing calls
no test coverage detected