| 102 | } |
| 103 | |
| 104 | bool vtkPythonGetStringValue(PyObject* o, const char*& a, const char* exctext) |
| 105 | { |
| 106 | if (PyBytes_Check(o)) |
| 107 | { |
| 108 | a = PyBytes_AsString(o); |
| 109 | return true; |
| 110 | } |
| 111 | else if (PyByteArray_Check(o)) |
| 112 | { |
| 113 | a = PyByteArray_AsString(o); |
| 114 | return true; |
| 115 | } |
| 116 | else if (PyUnicode_Check(o)) |
| 117 | { |
| 118 | a = PyUnicode_AsUTF8AndSize(o, nullptr); |
| 119 | return true; |
| 120 | } |
| 121 | |
| 122 | if (exctext) |
| 123 | { |
| 124 | PyErr_SetString(PyExc_TypeError, exctext); |
| 125 | } |
| 126 | return false; |
| 127 | } |
| 128 | |
| 129 | inline bool vtkPythonGetStdStringValue(PyObject* o, std::string& a, const char* exctext) |
| 130 | { |
no outgoing calls
no test coverage detected