Conversion function extracting a const char** device name from a PyObject. The function should be used with PyArg_Parse* APIs.
| 168 | // Conversion function extracting a const char** device name from a PyObject. |
| 169 | // The function should be used with PyArg_Parse* APIs. |
| 170 | int ConvertDeviceName(PyObject* obj, const char** dst) { |
| 171 | if (obj == Py_None) { |
| 172 | *dst = nullptr; |
| 173 | } else { |
| 174 | auto device_name = TFE_GetPythonString(obj); |
| 175 | if (device_name == nullptr) { |
| 176 | PyErr_Clear(); |
| 177 | PyErr_SetString(PyExc_TypeError, "Error parsing device argument."); |
| 178 | return 0; |
| 179 | } |
| 180 | *dst = device_name; |
| 181 | } |
| 182 | |
| 183 | return 1; |
| 184 | } |
| 185 | |
| 186 | } // namespace |
| 187 |
nothing calls this directly
no test coverage detected