]> granicus.if.org Git - python/commitdiff
Merged revisions 71722,71725 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Sat, 18 Apr 2009 20:50:24 +0000 (20:50 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sat, 18 Apr 2009 20:50:24 +0000 (20:50 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71722 | benjamin.peterson | 2009-04-18 15:12:47 -0500 (Sat, 18 Apr 2009) | 1 line

  try to initalize all builtin types with PyType_Ready to avoid problems like #5787
........
  r71725 | benjamin.peterson | 2009-04-18 15:25:25 -0500 (Sat, 18 Apr 2009) | 1 line

  initalize -> initialize
........

Lib/test/test_descr.py
Misc/NEWS
Objects/frameobject.c
Objects/object.c

index b57e0fae05b928375eab3fede8f977f58dedd977..554e1c8a65a95e29b194fdabf901723b634ca0a6 100644 (file)
@@ -1,3 +1,4 @@
+import __builtin__
 import types
 import unittest
 import warnings
@@ -3838,6 +3839,17 @@ order (MRO) for bases """
         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):
index ef833c906c126957bebcafa3152cbcb8a97d1c62..e1f2630da9dfa76b8d2352159ee8d78cd62e7bf3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,9 +12,12 @@ What's New in Python 2.6.3
 Core and Builtins
 -----------------
 
+- Issue #5787: object.__getattribute__(some_type, "__bases__") segfaulted on
+  some builtin types.
+
 - Issue #5759: float() didn't call __float__ on str subclasses.
 
-Library
+Librar
 -------
 
 - Issue #5768: Fixed bug in Unicode output logic and test case for same.
index 9a37b62a1d86e29374e3727200c3ab2cdd203aef..5b2f3083f971c874e48b0f3c665168a4393aeec5 100644 (file)
@@ -574,14 +574,6 @@ int _PyFrame_Init()
        builtin_object = PyString_InternFromString("__builtins__");
        if (builtin_object == NULL)
                return 0;
-       /* 
-          Traceback objects are not created the normal way (through calling the
-          type), so PyType_Ready has to be called here.
-       */
-       if (PyType_Ready(&PyTraceBack_Type)) {
-               Py_DECREF(builtin_object);
-               return 0;
-       }
        return 1;
 }
 
index e2ec93b8c3b20595ec79dbfcacdd8465126b931d..898aa6559d0366ca28f8323975221fc76b253ee1 100644 (file)
@@ -2022,28 +2022,85 @@ void
 _Py_ReadyTypes(void)
 {
        if (PyType_Ready(&PyType_Type) < 0)
-               Py_FatalError("Can't initialize 'type'");
+               Py_FatalError("Can't initialize type type");
 
        if (PyType_Ready(&_PyWeakref_RefType) < 0)
-               Py_FatalError("Can't initialize 'weakref'");
+               Py_FatalError("Can't initialize weakref type");
 
        if (PyType_Ready(&PyBool_Type) < 0)
-               Py_FatalError("Can't initialize 'bool'");
+               Py_FatalError("Can't initialize bool type");
 
        if (PyType_Ready(&PyString_Type) < 0)
-               Py_FatalError("Can't initialize 'str'");
+               Py_FatalError("Can't initialize str type");
 
        if (PyType_Ready(&PyByteArray_Type) < 0)
-               Py_FatalError("Can't initialize 'bytes'");
+               Py_FatalError("Can't initialize bytearray");
 
        if (PyType_Ready(&PyList_Type) < 0)
-               Py_FatalError("Can't initialize 'list'");
+               Py_FatalError("Can't initialize list");
 
        if (PyType_Ready(&PyNone_Type) < 0)
-               Py_FatalError("Can't initialize type(None)");
+               Py_FatalError("Can't initialize None type");
 
        if (PyType_Ready(&PyNotImplemented_Type) < 0)
-               Py_FatalError("Can't initialize type(NotImplemented)");
+               Py_FatalError("Can't initialize NotImplemented type");
+
+       if (PyType_Ready(&PyTraceBack_Type) < 0)
+               Py_FatalError("Can't initialize traceback type");
+
+       if (PyType_Ready(&PySuper_Type) < 0)
+               Py_FatalError("Can't initialize super type");
+
+       if (PyType_Ready(&PyBaseObject_Type) < 0)
+               Py_FatalError("Can't initialize object type");
+
+       if (PyType_Ready(&PyRange_Type) < 0)
+               Py_FatalError("Can't initialize xrange type");
+
+       if (PyType_Ready(&PyDict_Type) < 0)
+               Py_FatalError("Can't initialize dict type");
+
+       if (PyType_Ready(&PySet_Type) < 0)
+               Py_FatalError("Can't initialize set type");
+
+       if (PyType_Ready(&PyUnicode_Type) < 0)
+               Py_FatalError("Can't initialize unicode type");
+
+       if (PyType_Ready(&PySlice_Type) < 0)
+               Py_FatalError("Can't initialize slice type");
+
+       if (PyType_Ready(&PyStaticMethod_Type) < 0)
+               Py_FatalError("Can't initialize static method type");
+
+       if (PyType_Ready(&PyComplex_Type) < 0)
+               Py_FatalError("Can't initalize complex type");
+
+       if (PyType_Ready(&PyFloat_Type) < 0)
+               Py_FatalError("Can't initialize float type");
+
+       if (PyType_Ready(&PyBuffer_Type) < 0)
+               Py_FatalError("Can't initialize buffer type");
+
+       if (PyType_Ready(&PyLong_Type) < 0)
+               Py_FatalError("Can't initialize long type");
+
+       if (PyType_Ready(&PyInt_Type) < 0)
+               Py_FatalError("Can't initialize int type");
+
+       if (PyType_Ready(&PyFrozenSet_Type) < 0)
+               Py_FatalError("Can't initialize frozenset type");
+
+       if (PyType_Ready(&PyProperty_Type) < 0)
+               Py_FatalError("Can't initialize property type");
+
+       if (PyType_Ready(&PyTuple_Type) < 0)
+               Py_FatalError("Can't initialize tuple type");
+
+       if (PyType_Ready(&PyEnum_Type) < 0)
+               Py_FatalError("Can't initialize enumerate type");
+
+       if (PyType_Ready(&PyReversed_Type) < 0)
+               Py_FatalError("Can't initialize reversed type");
 }