* Attempt to convert a C string to a Python string with the given encoding. * If the conversion fails, return a fallback string. */
| 41 | * If the conversion fails, return a fallback string. |
| 42 | */ |
| 43 | PyObject * |
| 44 | to_unicode_safe(const char *value, const char *encoding) |
| 45 | { |
| 46 | PyObject *py_str; |
| 47 | |
| 48 | if (!value) { |
| 49 | py_str = PyUnicode_FromString("None"); |
| 50 | } else { |
| 51 | py_str = to_unicode(value, encoding, "replace"); |
| 52 | |
| 53 | if (!py_str) { |
| 54 | assert(PyErr_Occurred()); |
| 55 | py_str = PyUnicode_FromString("(error)"); |
| 56 | PyErr_Clear(); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | assert(!PyErr_Occurred()); |
| 61 | assert(py_str); |
| 62 | |
| 63 | return py_str; |
| 64 | } |
| 65 | |
| 66 | char* |
| 67 | pgit_borrow_fsdefault(PyObject *value, PyObject **tvalue) |
no outgoing calls
no test coverage detected
searching dependent graphs…