MCPcopy Create free account
hub / github.com/blender/blender / Vector_ass_subscript

Function Vector_ass_subscript

source/blender/python/mathutils/mathutils_Vector.cc:2013–2043  ·  view source on GitHub ↗

Sequence generic subscript (set): `object[...] = x`. */

Source from the content-addressed store, hash-verified

2011
2012/** Sequence generic subscript (set): `object[...] = x`. */
2013static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *value)
2014{
2015 if (PyIndex_Check(item)) {
2016 Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
2017 if (i == -1 && PyErr_Occurred()) {
2018 return -1;
2019 }
2020 if (i < 0) {
2021 i += self->vec_num;
2022 }
2023 return Vector_ass_item(self, i, value);
2024 }
2025 if (PySlice_Check(item)) {
2026 Py_ssize_t start, stop, step, slicelength;
2027
2028 if (PySlice_GetIndicesEx(item, self->vec_num, &start, &stop, &step, &slicelength) < 0) {
2029 return -1;
2030 }
2031
2032 if (step == 1) {
2033 return Vector_ass_slice(self, start, stop, value);
2034 }
2035
2036 PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
2037 return -1;
2038 }
2039
2040 PyErr_Format(
2041 PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
2042 return -1;
2043}
2044
2045/** \} */
2046

Callers

nothing calls this directly

Calls 2

Vector_ass_itemFunction · 0.85
Vector_ass_sliceFunction · 0.85

Tested by

no test coverage detected