bpo-44110: Improve string's __getitem__ error message (GH-26042)

This commit is contained in:
Miguel Brito 2021-06-27 13:04:57 +01:00 committed by GitHub
parent 7569c0fe91
commit ed1076428c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 3 deletions

View file

@ -14279,7 +14279,8 @@ unicode_subscript(PyObject* self, PyObject* item)
assert(_PyUnicode_CheckConsistency(result, 1));
return result;
} else {
PyErr_SetString(PyExc_TypeError, "string indices must be integers");
PyErr_Format(PyExc_TypeError, "string indices must be integers, not '%.200s'",
Py_TYPE(item)->tp_name);
return NULL;
}
}