MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / apply_slice

Function apply_slice

edrav2/eprj/boost/libs/python/src/object_protocol.cpp:103–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 #define ISINT(x) ((x) == NULL || PyInt_Check(x) || PyLong_Check(x))
102
103 static PyObject *
104 apply_slice(PyObject *u, PyObject *v, PyObject *w) /* return u[v:w] */
105 {
106#if PY_VERSION_HEX < 0x03000000
107 PyTypeObject *tp = u->ob_type;
108 PySequenceMethods *sq = tp->tp_as_sequence;
109
110 if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) {
111 ssize_t ilow = 0, ihigh = ssize_t_max;
112 if (!_PyEval_SliceIndex(v, &ilow))
113 return NULL;
114 if (!_PyEval_SliceIndex(w, &ihigh))
115 return NULL;
116 return PySequence_GetSlice(u, ilow, ihigh);
117 }
118 else
119#endif
120 {
121 PyObject *slice = PySlice_New(v, w, NULL);
122 if (slice != NULL) {
123 PyObject *res = PyObject_GetItem(u, slice);
124 Py_DECREF(slice);
125 return res;
126 }
127 else
128 return NULL;
129 }
130 }
131
132 static int
133 assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x)

Callers 1

getsliceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected