MCPcopy Create free account
hub / github.com/libgit2/pygit2 / to_unicode_safe

Function to_unicode_safe

src/utils.c:43–64  ·  view source on GitHub ↗

* Attempt to convert a C string to a Python string with the given encoding. * If the conversion fails, return a fallback string. */

Source from the content-addressed store, hash-verified

41 * If the conversion fails, return a fallback string.
42 */
43PyObject *
44to_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
66char*
67pgit_borrow_fsdefault(PyObject *value, PyObject **tvalue)

Callers 4

FilterSource_path__get__Function · 0.85
pygit2_filter_checkFunction · 0.85
Signature__str__Function · 0.85
Signature__repr__Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…