/src/cpython/Python/config_common.h
Line | Count | Source (jump to first uncovered line) |
1 | | |
2 | | static inline int |
3 | | _config_dict_get(PyObject *dict, const char *name, PyObject **p_item) |
4 | 1.10k | { |
5 | 1.10k | PyObject *item; |
6 | 1.10k | if (PyDict_GetItemStringRef(dict, name, &item) < 0) { |
7 | 0 | return -1; |
8 | 0 | } |
9 | 1.10k | if (item == NULL) { |
10 | | // We do not set an exception. |
11 | 0 | return -1; |
12 | 0 | } |
13 | 1.10k | *p_item = item; |
14 | 1.10k | return 0; |
15 | 1.10k | } |
16 | | |
17 | | |
18 | | static PyObject* |
19 | | config_dict_get(PyObject *dict, const char *name) |
20 | 1.10k | { |
21 | 1.10k | PyObject *item; |
22 | 1.10k | if (_config_dict_get(dict, name, &item) < 0) { |
23 | 0 | if (!PyErr_Occurred()) { |
24 | 0 | PyErr_Format(PyExc_ValueError, "missing config key: %s", name); |
25 | 0 | } |
26 | 0 | return NULL; |
27 | 0 | } |
28 | 1.10k | return item; |
29 | 1.10k | } |
30 | | |
31 | | |
32 | | static void |
33 | | config_dict_invalid_type(const char *name) |
34 | 0 | { |
35 | 0 | PyErr_Format(PyExc_TypeError, "invalid config type: %s", name); |
36 | 0 | } |