| 175 | /************************************************************************/ |
| 176 | |
| 177 | static int GetIntRes(PyObject *poObj, const char *pszFunctionName) |
| 178 | { |
| 179 | PyObject *poMethod = PyObject_GetAttrString(poObj, pszFunctionName); |
| 180 | if (poMethod == nullptr || PyErr_Occurred()) |
| 181 | { |
| 182 | CPLError(CE_Failure, CPLE_AppDefined, "%s", |
| 183 | GetPyExceptionString().c_str()); |
| 184 | return 0; |
| 185 | } |
| 186 | |
| 187 | PyObject *poMethodRes = CallPython(poMethod); |
| 188 | if (ErrOccurredEmitCPLError()) |
| 189 | { |
| 190 | Py_DecRef(poMethod); |
| 191 | return 0; |
| 192 | } |
| 193 | Py_DecRef(poMethod); |
| 194 | |
| 195 | int nRes = static_cast<int>(PyLong_AsLong(poMethodRes)); |
| 196 | if (ErrOccurredEmitCPLError()) |
| 197 | { |
| 198 | Py_DecRef(poMethodRes); |
| 199 | return 0; |
| 200 | } |
| 201 | |
| 202 | Py_DecRef(poMethodRes); |
| 203 | return nRes; |
| 204 | } |
| 205 | |
| 206 | /************************************************************************/ |
| 207 | /* GetDict() */ |
no test coverage detected