* Return a borrowed c string with the representation of the given Unicode or * Bytes object: * - If value is Unicode return the UTF-8 representation * - If value is Bytes return the raw sttring * In both cases the returned string is owned by value and must not be * modified, nor freed. */
| 137 | * modified, nor freed. |
| 138 | */ |
| 139 | const char* |
| 140 | pgit_borrow(PyObject *value) |
| 141 | { |
| 142 | if (PyUnicode_Check(value)) { // Text string |
| 143 | return PyUnicode_AsUTF8(value); |
| 144 | } else if (PyBytes_Check(value)) { // Byte string |
| 145 | return PyBytes_AsString(value); |
| 146 | } |
| 147 | |
| 148 | // Type error |
| 149 | Error_type_error("unexpected %.200s", value); |
| 150 | return NULL; |
| 151 | } |
| 152 | |
| 153 | |
| 154 | char* |
no test coverage detected
searching dependent graphs…