| 395 | } |
| 396 | |
| 397 | PyObject* |
| 398 | raise_feature_unavailable(const char* message, const char* file, int line) |
| 399 | { |
| 400 | // TODO: is this possible? |
| 401 | if (cached_feature_unavailable_exc == nullptr) { |
| 402 | // Fallback to ValueError if exception not cached yet |
| 403 | PyErr_SetString(PyExc_ValueError, message); |
| 404 | return nullptr; |
| 405 | } |
| 406 | |
| 407 | PyObject* args = PyTuple_New(0); |
| 408 | PyObject* kwargs = PyDict_New(); |
| 409 | PyDict_SetItemString(kwargs, "message", PyUnicode_FromString(message)); |
| 410 | |
| 411 | PyObject* exc_info = build_exc_info_dict(file, line, message); |
| 412 | if (exc_info != nullptr) { |
| 413 | PyDict_SetItemString(kwargs, "exc_info", exc_info); |
| 414 | Py_DECREF(exc_info); |
| 415 | } |
| 416 | |
| 417 | PyObject* exc = PyObject_Call(cached_feature_unavailable_exc, args, kwargs); |
| 418 | Py_DECREF(args); |
| 419 | Py_DECREF(kwargs); |
| 420 | |
| 421 | if (exc != nullptr) { |
| 422 | PyErr_SetObject(cached_feature_unavailable_exc, exc); |
| 423 | Py_DECREF(exc); |
| 424 | } |
| 425 | |
| 426 | return nullptr; |
| 427 | } |
| 428 | |
| 429 | PyObject* |
| 430 | raise_unsuccessful_operation(const char* message, const char* file, int line) |
no outgoing calls
no test coverage detected