@@ -1745,82 +1745,87 @@ _PyTypes_Init(void)
1745
1745
return status ;
1746
1746
}
1747
1747
1748
- #define INIT_TYPE (TYPE , NAME ) \
1748
+ #define INIT_TYPE (TYPE ) \
1749
1749
do { \
1750
- if (PyType_Ready(TYPE) < 0) { \
1751
- return _PyStatus_ERR("Can't initialize " NAME " type"); \
1750
+ if (PyType_Ready(&( TYPE) ) < 0) { \
1751
+ return _PyStatus_ERR("Can't initialize " #TYPE " type"); \
1752
1752
} \
1753
1753
} while (0)
1754
1754
1755
- INIT_TYPE (& PyBaseObject_Type , "object" );
1756
- INIT_TYPE (& PyType_Type , "type" );
1757
- INIT_TYPE (& _PyWeakref_RefType , "weakref" );
1758
- INIT_TYPE (& _PyWeakref_CallableProxyType , "callable weakref proxy" );
1759
- INIT_TYPE (& _PyWeakref_ProxyType , "weakref proxy" );
1760
- INIT_TYPE (& PyLong_Type , "int" );
1761
- INIT_TYPE (& PyBool_Type , "bool" );
1762
- INIT_TYPE (& PyByteArray_Type , "bytearray" );
1763
- INIT_TYPE (& PyBytes_Type , "str" );
1764
- INIT_TYPE (& PyList_Type , "list" );
1765
- INIT_TYPE (& _PyNone_Type , "None" );
1766
- INIT_TYPE (& _PyNotImplemented_Type , "NotImplemented" );
1767
- INIT_TYPE (& PyTraceBack_Type , "traceback" );
1768
- INIT_TYPE (& PySuper_Type , "super" );
1769
- INIT_TYPE (& PyRange_Type , "range" );
1770
- INIT_TYPE (& PyDict_Type , "dict" );
1771
- INIT_TYPE (& PyDictKeys_Type , "dict keys" );
1772
- INIT_TYPE (& PyDictValues_Type , "dict values" );
1773
- INIT_TYPE (& PyDictItems_Type , "dict items" );
1774
- INIT_TYPE (& PyDictRevIterKey_Type , "reversed dict keys" );
1775
- INIT_TYPE (& PyDictRevIterValue_Type , "reversed dict values" );
1776
- INIT_TYPE (& PyDictRevIterItem_Type , "reversed dict items" );
1777
- INIT_TYPE (& PyODict_Type , "OrderedDict" );
1778
- INIT_TYPE (& PyODictKeys_Type , "odict_keys" );
1779
- INIT_TYPE (& PyODictItems_Type , "odict_items" );
1780
- INIT_TYPE (& PyODictValues_Type , "odict_values" );
1781
- INIT_TYPE (& PyODictIter_Type , "odict_keyiterator" );
1782
- INIT_TYPE (& PySet_Type , "set" );
1783
- INIT_TYPE (& PyUnicode_Type , "str" );
1784
- INIT_TYPE (& PySlice_Type , "slice" );
1785
- INIT_TYPE (& PyStaticMethod_Type , "static method" );
1786
- INIT_TYPE (& PyComplex_Type , "complex" );
1787
- INIT_TYPE (& PyFloat_Type , "float" );
1788
- INIT_TYPE (& PyFrozenSet_Type , "frozenset" );
1789
- INIT_TYPE (& PyProperty_Type , "property" );
1790
- INIT_TYPE (& _PyManagedBuffer_Type , "managed buffer" );
1791
- INIT_TYPE (& PyMemoryView_Type , "memoryview" );
1792
- INIT_TYPE (& PyTuple_Type , "tuple" );
1793
- INIT_TYPE (& PyEnum_Type , "enumerate" );
1794
- INIT_TYPE (& PyReversed_Type , "reversed" );
1795
- INIT_TYPE (& PyStdPrinter_Type , "StdPrinter" );
1796
- INIT_TYPE (& PyCode_Type , "code" );
1797
- INIT_TYPE (& PyFrame_Type , "frame" );
1798
- INIT_TYPE (& PyCFunction_Type , "builtin function" );
1799
- INIT_TYPE (& PyCMethod_Type , "builtin method" );
1800
- INIT_TYPE (& PyMethod_Type , "method" );
1801
- INIT_TYPE (& PyFunction_Type , "function" );
1802
- INIT_TYPE (& PyDictProxy_Type , "dict proxy" );
1803
- INIT_TYPE (& PyGen_Type , "generator" );
1804
- INIT_TYPE (& PyGetSetDescr_Type , "get-set descriptor" );
1805
- INIT_TYPE (& PyWrapperDescr_Type , "wrapper" );
1806
- INIT_TYPE (& _PyMethodWrapper_Type , "method wrapper" );
1807
- INIT_TYPE (& PyEllipsis_Type , "ellipsis" );
1808
- INIT_TYPE (& PyMemberDescr_Type , "member descriptor" );
1809
- INIT_TYPE (& _PyNamespace_Type , "namespace" );
1810
- INIT_TYPE (& PyCapsule_Type , "capsule" );
1811
- INIT_TYPE (& PyLongRangeIter_Type , "long range iterator" );
1812
- INIT_TYPE (& PyCell_Type , "cell" );
1813
- INIT_TYPE (& PyInstanceMethod_Type , "instance method" );
1814
- INIT_TYPE (& PyClassMethodDescr_Type , "class method descr" );
1815
- INIT_TYPE (& PyMethodDescr_Type , "method descr" );
1816
- INIT_TYPE (& PyCallIter_Type , "call iter" );
1817
- INIT_TYPE (& PySeqIter_Type , "sequence iterator" );
1818
- INIT_TYPE (& PyPickleBuffer_Type , "pickle.PickleBuffer" );
1819
- INIT_TYPE (& PyCoro_Type , "coroutine" );
1820
- INIT_TYPE (& _PyCoroWrapper_Type , "coroutine wrapper" );
1821
- INIT_TYPE (& _PyInterpreterID_Type , "interpreter ID" );
1822
- return _PyStatus_OK ();
1755
+ // Base types
1756
+ INIT_TYPE (PyBaseObject_Type );
1757
+ INIT_TYPE (PyType_Type );
1758
+ assert (PyBaseObject_Type .tp_base == NULL );
1759
+ assert (PyType_Type .tp_base == & PyBaseObject_Type );
1760
+
1761
+ // All other static types
1762
+ INIT_TYPE (PyBool_Type );
1763
+ INIT_TYPE (PyByteArray_Type );
1764
+ INIT_TYPE (PyBytes_Type );
1765
+ INIT_TYPE (PyCFunction_Type );
1766
+ INIT_TYPE (PyCMethod_Type );
1767
+ INIT_TYPE (PyCallIter_Type );
1768
+ INIT_TYPE (PyCapsule_Type );
1769
+ INIT_TYPE (PyCell_Type );
1770
+ INIT_TYPE (PyClassMethodDescr_Type );
1771
+ INIT_TYPE (PyCode_Type );
1772
+ INIT_TYPE (PyComplex_Type );
1773
+ INIT_TYPE (PyCoro_Type );
1774
+ INIT_TYPE (PyDictItems_Type );
1775
+ INIT_TYPE (PyDictKeys_Type );
1776
+ INIT_TYPE (PyDictProxy_Type );
1777
+ INIT_TYPE (PyDictRevIterItem_Type );
1778
+ INIT_TYPE (PyDictRevIterKey_Type );
1779
+ INIT_TYPE (PyDictRevIterValue_Type );
1780
+ INIT_TYPE (PyDictValues_Type );
1781
+ INIT_TYPE (PyDict_Type );
1782
+ INIT_TYPE (PyEllipsis_Type );
1783
+ INIT_TYPE (PyEnum_Type );
1784
+ INIT_TYPE (PyFloat_Type );
1785
+ INIT_TYPE (PyFrame_Type );
1786
+ INIT_TYPE (PyFrozenSet_Type );
1787
+ INIT_TYPE (PyFunction_Type );
1788
+ INIT_TYPE (PyGen_Type );
1789
+ INIT_TYPE (PyGetSetDescr_Type );
1790
+ INIT_TYPE (PyInstanceMethod_Type );
1791
+ INIT_TYPE (PyList_Type );
1792
+ INIT_TYPE (PyLongRangeIter_Type );
1793
+ INIT_TYPE (PyLong_Type );
1794
+ INIT_TYPE (PyMemberDescr_Type );
1795
+ INIT_TYPE (PyMemoryView_Type );
1796
+ INIT_TYPE (PyMethodDescr_Type );
1797
+ INIT_TYPE (PyMethod_Type );
1798
+ INIT_TYPE (PyODictItems_Type );
1799
+ INIT_TYPE (PyODictIter_Type );
1800
+ INIT_TYPE (PyODictKeys_Type );
1801
+ INIT_TYPE (PyODictValues_Type );
1802
+ INIT_TYPE (PyODict_Type );
1803
+ INIT_TYPE (PyPickleBuffer_Type );
1804
+ INIT_TYPE (PyProperty_Type );
1805
+ INIT_TYPE (PyRange_Type );
1806
+ INIT_TYPE (PyReversed_Type );
1807
+ INIT_TYPE (PySeqIter_Type );
1808
+ INIT_TYPE (PySet_Type );
1809
+ INIT_TYPE (PySlice_Type );
1810
+ INIT_TYPE (PyStaticMethod_Type );
1811
+ INIT_TYPE (PyStdPrinter_Type );
1812
+ INIT_TYPE (PySuper_Type );
1813
+ INIT_TYPE (PyTraceBack_Type );
1814
+ INIT_TYPE (PyTuple_Type );
1815
+ INIT_TYPE (PyUnicode_Type );
1816
+ INIT_TYPE (PyWrapperDescr_Type );
1817
+ INIT_TYPE (_PyCoroWrapper_Type );
1818
+ INIT_TYPE (_PyInterpreterID_Type );
1819
+ INIT_TYPE (_PyManagedBuffer_Type );
1820
+ INIT_TYPE (_PyMethodWrapper_Type );
1821
+ INIT_TYPE (_PyNamespace_Type );
1822
+ INIT_TYPE (_PyNone_Type );
1823
+ INIT_TYPE (_PyNotImplemented_Type );
1824
+ INIT_TYPE (_PyWeakref_CallableProxyType );
1825
+ INIT_TYPE (_PyWeakref_ProxyType );
1826
+ INIT_TYPE (_PyWeakref_RefType );
1823
1827
1828
+ return _PyStatus_OK ();
1824
1829
#undef INIT_TYPE
1825
1830
}
1826
1831
0 commit comments