Handle allocation failures gracefully.  Found with failmalloc.
Many (all?) of these could be backported.
diff --git a/Misc/NEWS b/Misc/NEWS
index 7339db2..43bede1 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@
 Core and builtins
 -----------------
 
+- Fix some potential crashes found with failmalloc.
+
 - Fix warnings reported by Klocwork's static analysis tool.
 
 - Bug #1512814, Fix incorrect lineno's when code within a function