| 67 | PYGIT2_FN_UNUSED |
| 68 | Py_LOCAL_INLINE(PyObject*) |
| 69 | to_unicode_n(const char *value, size_t len, const char *encoding, |
| 70 | const char *errors) |
| 71 | { |
| 72 | if (encoding == NULL) { |
| 73 | encoding = "utf-8"; // Default to UTF-8 |
| 74 | |
| 75 | /* If the encoding is not explicit, it may not be UTF-8, so it is not |
| 76 | * safe to decode it strictly. This is rare in the wild, but does |
| 77 | * occur in old commits to git itself (e.g. c31820c2). |
| 78 | * https://github.com/libgit2/pygit2/issues/77 |
| 79 | */ |
| 80 | if (errors == NULL) { |
| 81 | errors = "replace"; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | return PyUnicode_Decode(value, len, encoding, errors); |
| 86 | } |
| 87 | |
| 88 | #define value_or_default(x, _default) ((x) == NULL ? (_default) : (x)) |
| 89 |
no outgoing calls
no test coverage detected
searching dependent graphs…