diff --git a/Objects/listobject.c b/Objects/listobject.c index 83dfb7da01dfc3..e8fe246b56a703 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -692,14 +692,24 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) goto Error; } } - memcpy(recycle, &item[ilow], s); + if (norig==1) + recycle[0] = item[ilow]; + else { + memcpy(recycle, &item[ilow], s); + } } if (d < 0) { /* Delete -d items */ - Py_ssize_t tail; - tail = (Py_SIZE(a) - ihigh) * sizeof(PyObject *); - memmove(&item[ihigh+d], &item[ihigh], tail); + if((Py_SIZE(a) - ihigh)==1) { + item[ihigh-1] = item[ihigh]; + } + else { + Py_ssize_t tail; + tail = (Py_SIZE(a) - ihigh) * sizeof(PyObject *); + memmove(&item[ihigh+d], &item[ihigh], tail); + } if (list_resize(a, Py_SIZE(a) + d) < 0) { + Py_ssize_t tail = (Py_SIZE(a) - ihigh) * sizeof(PyObject *); memmove(&item[ihigh], &item[ihigh+d], tail); memcpy(&item[ilow], recycle, s); goto Error;