| 51 | } |
| 52 | |
| 53 | size_t |
| 54 | py_hex_to_git_oid(PyObject *py_oid, git_oid *oid) |
| 55 | { |
| 56 | PyObject *py_hex; |
| 57 | int err; |
| 58 | char *hex; |
| 59 | Py_ssize_t len; |
| 60 | |
| 61 | /* Unicode */ |
| 62 | if (PyUnicode_Check(py_oid)) { |
| 63 | py_hex = PyUnicode_AsASCIIString(py_oid); |
| 64 | if (py_hex == NULL) |
| 65 | return 0; |
| 66 | |
| 67 | err = PyBytes_AsStringAndSize(py_hex, &hex, &len); |
| 68 | if (err) { |
| 69 | Py_DECREF(py_hex); |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | err = git_oid_fromstrn(oid, hex, len); |
| 74 | Py_DECREF(py_hex); |
| 75 | if (err < 0) { |
| 76 | PyErr_SetObject(Error_type(err), py_oid); |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | return (size_t)len; |
| 81 | } |
| 82 | |
| 83 | /* Type error */ |
| 84 | PyErr_SetObject(PyExc_TypeError, py_oid); |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | size_t |
| 89 | py_oid_to_git_oid(PyObject *py_oid, git_oid *oid) |
no test coverage detected
searching dependent graphs…