| 87 | } |
| 88 | |
| 89 | int |
| 90 | Tree_fix_index(const git_tree *tree, PyObject *py_index) |
| 91 | { |
| 92 | long index; |
| 93 | size_t len; |
| 94 | long slen; |
| 95 | |
| 96 | index = PyLong_AsLong(py_index); |
| 97 | if (PyErr_Occurred()) |
| 98 | return -1; |
| 99 | |
| 100 | len = git_tree_entrycount(tree); |
| 101 | slen = (long)len; |
| 102 | if (index >= slen) { |
| 103 | PyErr_SetObject(PyExc_IndexError, py_index); |
| 104 | return -1; |
| 105 | } |
| 106 | else if (index < -slen) { |
| 107 | PyErr_SetObject(PyExc_IndexError, py_index); |
| 108 | return -1; |
| 109 | } |
| 110 | |
| 111 | /* This function is called via mp_subscript, which doesn't do negative |
| 112 | * index rewriting, so we have to do it manually. */ |
| 113 | if (index < 0) |
| 114 | index = len + index; |
| 115 | return (int)index; |
| 116 | } |
| 117 | |
| 118 | PyObject * |
| 119 | Tree_iter(Tree *self) |
no outgoing calls
no test coverage detected
searching dependent graphs…