if value == entry:
return position
else:
- raise ValueError(f"{value!r} not in this container")
+ raise ValueError("ShareableList.index(x): x not in list")
__class_getitem__ = classmethod(types.GenericAlias)
--- /dev/null
+:exc:`ValueError` messages for :meth:`!list.index()`, :meth:`!range.index()`,
+:meth:`!deque.index()`, :meth:`!deque.remove()` and
+:meth:`!ShareableList.index()` no longer contain the repr of the searched
+value (which can be arbitrary large) and are consistent with error messages
+for other :meth:`!index()` and :meth:`!remove()` methods.
index = 0;
}
}
- PyErr_Format(PyExc_ValueError, "%R is not in deque", v);
+ PyErr_SetString(PyExc_ValueError, "deque.index(x): x not in deque");
return NULL;
}
}
}
if (i == n) {
- PyErr_Format(PyExc_ValueError, "%R is not in deque", value);
+ PyErr_SetString(PyExc_ValueError, "deque.remove(x): x not in deque");
return NULL;
}
rv = deque_del_item(deque, i);
else if (cmp < 0)
return NULL;
}
- PyErr_Format(PyExc_ValueError, "%R is not in list", value);
+ PyErr_SetString(PyExc_ValueError, "list.index(x): x not in list");
return NULL;
}
}
/* object is not in the range */
- PyErr_Format(PyExc_ValueError, "%R is not in range", ob);
+ PyErr_SetString(PyExc_ValueError, "range.index(x): x not in range");
return NULL;
}