gh-152951 - Fix double DECREF when `newblock` fails during deque.extend calls (GH-152961)
(cherry picked from commit
a90576d72c8a409f7c3ffcaefafb13945e3405ab)
Co-authored-by: Steve Stagg <stestagg@gmail.com>
--- /dev/null
+:class:`collections.deque` prevent rare crash when calling ``extend`` under
+high memory pressure conditions.
iternext = *Py_TYPE(it)->tp_iternext;
while ((item = iternext(it)) != NULL) {
if (deque_append_lock_held(deque, item, maxlen) == -1) {
- Py_DECREF(item);
Py_DECREF(it);
return NULL;
}