try to initalize all builtin types with PyType_Ready to avoid problems like #5787
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index aa5bde4..b5c767c 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1,3 +1,4 @@
+import __builtin__
 import types
 import unittest
 import warnings
@@ -3895,6 +3896,17 @@
         else:
             self.fail("new-style class must have a new-style base")
 
+    def test_builtin_bases(self):
+        # Make sure all the builtin types can have their base queried without
+        # segfaulting. See issue #5787.
+        builtin_types = [tp for tp in __builtin__.__dict__.itervalues()
+                         if isinstance(tp, type)]
+        for tp in builtin_types:
+            object.__getattribute__(tp, "__bases__")
+            if tp is not object:
+                self.assertEqual(len(tp.__bases__), 1, tp)
+
+
     def test_mutable_bases_with_failing_mro(self):
         # Testing mutable bases with failing mro...
         class WorkOnce(type):