bpo-35441: Remove dead and buggy code related to PyList_SetItem(). (GH-11033)

In _localemodule.c and selectmodule.c, remove dead code that would
cause double decrefs if run.

In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases
where a new list is populated and there is no possibility of an error.

In addition, check if the list changed size in the loop in array_array_fromlist().
(cherry picked from commit 99d56b5356)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
Miss Islington (bot) 2018-12-08 06:34:49 -08:00 committed by GitHub
parent ee2c5a8e2d
commit 8b7d8ac09c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 30 deletions

View file

@ -5056,7 +5056,7 @@ getarray(long a[256])
Py_DECREF(l);
return NULL;
}
PyList_SetItem(l, i, x);
PyList_SET_ITEM(l, i, x);
}
for (i = 0; i < 256; i++)
a[i] = 0;
@ -5078,7 +5078,7 @@ _Py_GetDXProfile(PyObject *self, PyObject *args)
Py_DECREF(l);
return NULL;
}
PyList_SetItem(l, i, x);
PyList_SET_ITEM(l, i, x);
}
return l;
#endif

View file

@ -2544,7 +2544,7 @@ makepathobject(const wchar_t *path, wchar_t delim)
Py_DECREF(v);
return NULL;
}
PyList_SetItem(v, i, w);
PyList_SET_ITEM(v, i, w);
if (*p == '\0')
break;
path = p+1;