| 337 | } |
| 338 | |
| 339 | PyObject* |
| 340 | raise_invalid_argument(const char* message, const char* file, int line) |
| 341 | { |
| 342 | // TODO: is this possible? |
| 343 | if (cached_invalid_argument_exc == nullptr) { |
| 344 | // Fallback to ValueError if exception not cached yet |
| 345 | PyErr_SetString(PyExc_ValueError, message); |
| 346 | return nullptr; |
| 347 | } |
| 348 | |
| 349 | PyObject* args = PyTuple_New(0); |
| 350 | PyObject* kwargs = PyDict_New(); |
| 351 | PyDict_SetItemString(kwargs, "message", PyUnicode_FromString(message)); |
| 352 | |
| 353 | PyObject* exc_info = build_exc_info_dict(file, line, message); |
| 354 | if (exc_info != nullptr) { |
| 355 | PyDict_SetItemString(kwargs, "exc_info", exc_info); |
| 356 | Py_DECREF(exc_info); |
| 357 | } |
| 358 | |
| 359 | PyObject* exc = PyObject_Call(cached_invalid_argument_exc, args, kwargs); |
| 360 | Py_DECREF(args); |
| 361 | Py_DECREF(kwargs); |
| 362 | |
| 363 | if (exc != nullptr) { |
| 364 | PyErr_SetObject(cached_invalid_argument_exc, exc); |
| 365 | Py_DECREF(exc); |
| 366 | } |
| 367 | |
| 368 | return nullptr; |
| 369 | } |
| 370 | |
| 371 | PyObject* |
| 372 | raise_required_field_missing(PyObject* interned_key, |
no outgoing calls
no test coverage detected