We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 77605fa commit de9deb7Copy full SHA for de9deb7
Objects/listobject.c
@@ -595,12 +595,8 @@ list_repr_impl(PyListObject *v)
595
/* Do repr() on each element. Note that this may mutate the list,
596
so must refetch the list size on each iteration. */
597
for (Py_ssize_t i = 0; i < Py_SIZE(v); ++i) {
598
- item = list_get_item_ref(v, i);
599
- if (item == NULL) {
600
- // List truncated while iterating on it
601
- PyErr_Clear();
602
- break;
603
- }
+ /* Hold a strong reference since repr(item) can mutate the list */
+ item = Py_NewRef(v->ob_item[i]);
604
605
if (i > 0) {
606
if (PyUnicodeWriter_WriteChar(writer, ',') < 0) {
0 commit comments