diff --git a/Include/internal/pycore_interp_structs.h b/Include/internal/pycore_interp_structs.h index 956fa290f0ad0e..f5a303c49a2288 100644 --- a/Include/internal/pycore_interp_structs.h +++ b/Include/internal/pycore_interp_structs.h @@ -529,17 +529,10 @@ struct _py_func_state { /****** type state *********/ -/* For now we hard-code this to a value for which we are confident - all the static builtin types will fit (for all builds). - If you add a new static type to the standard library, you may have to - update one of these numbers. - */ -#define _Py_NUM_MANAGED_PREINITIALIZED_TYPES 120 -#define _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES \ - (_Py_NUM_MANAGED_PREINITIALIZED_TYPES + 83) -#define _Py_MAX_MANAGED_STATIC_EXT_TYPES 10 -#define _Py_MAX_MANAGED_STATIC_TYPES \ - (_Py_MAX_MANAGED_STATIC_BUILTIN_TYPES + _Py_MAX_MANAGED_STATIC_EXT_TYPES) +/* All _Py_MAX_MANAGED_STATIC_* sizing macros are derived at compile + time from the X-macro lists in pycore_static_builtin_types.h, the + single source of truth for every static builtin registration. */ +#include "pycore_static_builtin_types.h" struct _types_runtime_state { /* Used to set PyTypeObject.tp_version_tag for core static types. */ diff --git a/Include/internal/pycore_static_builtin_types.h b/Include/internal/pycore_static_builtin_types.h new file mode 100644 index 00000000000000..9f9204aee03345 --- /dev/null +++ b/Include/internal/pycore_static_builtin_types.h @@ -0,0 +1,297 @@ +#ifndef Py_INTERNAL_STATIC_BUILTIN_TYPES_H +#define Py_INTERNAL_STATIC_BUILTIN_TYPES_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +/* Single source of truth for every static builtin type registered at + startup, partitioned by where it is registered. Adding a + registration anywhere in the tree requires adding an entry to the + matching list; _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES then adjusts at + compile time (gh-145497). */ + + +#ifdef _Py_TIER2 +# define _Py_FOREACH_TIER2_PREINIT_TYPE(TYPE) TYPE(_PyUOpExecutor_Type) +#else +# define _Py_FOREACH_TIER2_PREINIT_TYPE(TYPE) +#endif + +/* Registered via static_types[] in Objects/object.c. + Order matters: base types first; trailing subclasses last so + _PyTypes_FiniTypes() tears them down before their base. */ +#define _Py_FOREACH_STATIC_PREINIT_TYPE(TYPE) \ + TYPE(PyBaseObject_Type) \ + TYPE(PyType_Type) \ + TYPE(PyStaticMethod_Type) \ + TYPE(PyCFunction_Type) \ + \ + TYPE(PyAsyncGen_Type) \ + TYPE(PyByteArrayIter_Type) \ + TYPE(PyByteArray_Type) \ + TYPE(PyBytesIter_Type) \ + TYPE(PyBytes_Type) \ + TYPE(PyCallIter_Type) \ + TYPE(PyCapsule_Type) \ + TYPE(PyCell_Type) \ + TYPE(PyClassMethodDescr_Type) \ + TYPE(PyClassMethod_Type) \ + TYPE(PyCode_Type) \ + TYPE(PyComplex_Type) \ + TYPE(PyContextToken_Type) \ + TYPE(PyContextVar_Type) \ + TYPE(PyContext_Type) \ + TYPE(PyCoro_Type) \ + TYPE(PyDictItems_Type) \ + TYPE(PyDictIterItem_Type) \ + TYPE(PyDictIterKey_Type) \ + TYPE(PyDictIterValue_Type) \ + TYPE(PyDictKeys_Type) \ + TYPE(PyDictProxy_Type) \ + TYPE(PyDictRevIterItem_Type) \ + TYPE(PyDictRevIterKey_Type) \ + TYPE(PyDictRevIterValue_Type) \ + TYPE(PyDictValues_Type) \ + TYPE(PyDict_Type) \ + TYPE(PyEllipsis_Type) \ + TYPE(PyEnum_Type) \ + TYPE(PyFilter_Type) \ + TYPE(PyFloat_Type) \ + TYPE(PyFrameLocalsProxy_Type) \ + TYPE(PyFrame_Type) \ + TYPE(PyFrozenDict_Type) \ + TYPE(PyFrozenSet_Type) \ + TYPE(PyFunction_Type) \ + TYPE(PyGen_Type) \ + TYPE(PyGetSetDescr_Type) \ + TYPE(PyInstanceMethod_Type) \ + TYPE(PyLazyImport_Type) \ + TYPE(PyListIter_Type) \ + TYPE(PyListRevIter_Type) \ + TYPE(PyList_Type) \ + TYPE(PyLongRangeIter_Type) \ + TYPE(PyLong_Type) \ + TYPE(PyMap_Type) \ + TYPE(PyMemberDescr_Type) \ + TYPE(PyMemoryView_Type) \ + TYPE(PyMethodDescr_Type) \ + TYPE(PyMethod_Type) \ + TYPE(PyModuleDef_Type) \ + TYPE(PyModule_Type) \ + TYPE(PyODictIter_Type) \ + TYPE(PyPickleBuffer_Type) \ + TYPE(PyProperty_Type) \ + TYPE(PyRangeIter_Type) \ + TYPE(PyRange_Type) \ + TYPE(PyReversed_Type) \ + TYPE(PySTEntry_Type) \ + TYPE(PySentinel_Type) \ + TYPE(PySeqIter_Type) \ + TYPE(PySetIter_Type) \ + TYPE(PySet_Type) \ + TYPE(PySlice_Type) \ + TYPE(PyStdPrinter_Type) \ + TYPE(PySuper_Type) \ + TYPE(PyTraceBack_Type) \ + TYPE(PyTupleIter_Type) \ + TYPE(PyTuple_Type) \ + TYPE(PyUnicodeIter_Type) \ + TYPE(PyUnicode_Type) \ + TYPE(PyWrapperDescr_Type) \ + TYPE(PyZip_Type) \ + TYPE(Py_GenericAliasType) \ + TYPE(_PyAnextAwaitable_Type) \ + TYPE(_PyAsyncGenASend_Type) \ + TYPE(_PyAsyncGenAThrow_Type) \ + TYPE(_PyAsyncGenWrappedValue_Type) \ + TYPE(_PyBufferWrapper_Type) \ + TYPE(_PyContextTokenMissing_Type) \ + TYPE(_PyCoroWrapper_Type) \ + TYPE(_Py_GenericAliasIterType) \ + TYPE(_PyHamtItems_Type) \ + TYPE(_PyHamtKeys_Type) \ + TYPE(_PyHamtValues_Type) \ + TYPE(_PyHamt_ArrayNode_Type) \ + TYPE(_PyHamt_BitmapNode_Type) \ + TYPE(_PyHamt_CollisionNode_Type) \ + TYPE(_PyHamt_Type) \ + TYPE(_PyInstructionSequence_Type) \ + TYPE(_PyInterpolation_Type) \ + TYPE(_PyLegacyEventHandler_Type) \ + TYPE(_PyLineIterator) \ + TYPE(_PyManagedBuffer_Type) \ + TYPE(_PyMemoryIter_Type) \ + TYPE(_PyMethodWrapper_Type) \ + TYPE(_PyNamespace_Type) \ + TYPE(_PyNone_Type) \ + TYPE(_PyNotImplemented_Type) \ + TYPE(_PyPositionsIterator) \ + TYPE(_PyTemplate_Type) \ + TYPE(_PyTemplateIter_Type) \ + TYPE(_PyUnicodeASCIIIter_Type) \ + TYPE(_PyUnion_Type) \ + _Py_FOREACH_TIER2_PREINIT_TYPE(TYPE) \ + TYPE(_PyWeakref_CallableProxyType) \ + TYPE(_PyWeakref_ProxyType) \ + TYPE(_PyWeakref_RefType) \ + TYPE(_PyTypeAlias_Type) \ + TYPE(_PyNoDefault_Type) \ + \ + TYPE(PyBool_Type) \ + TYPE(PyCMethod_Type) \ + TYPE(PyODictItems_Type) \ + TYPE(PyODictKeys_Type) \ + TYPE(PyODictValues_Type) \ + TYPE(PyODict_Type) + + +/* Registered via static_exceptions[] in Objects/exceptions.c. + NAME is the suffix; the real type is &_PyExc_. */ +#define _Py_FOREACH_STATIC_EXCEPTION_TYPE(EXC) \ + EXC(BaseException) \ + \ + EXC(BaseExceptionGroup) \ + EXC(Exception) \ + EXC(GeneratorExit) \ + EXC(KeyboardInterrupt) \ + EXC(SystemExit) \ + \ + EXC(ArithmeticError) \ + EXC(AssertionError) \ + EXC(AttributeError) \ + EXC(BufferError) \ + EXC(EOFError) \ + EXC(ImportError) \ + EXC(LookupError) \ + EXC(MemoryError) \ + EXC(NameError) \ + EXC(OSError) \ + EXC(ReferenceError) \ + EXC(RuntimeError) \ + EXC(StopAsyncIteration) \ + EXC(StopIteration) \ + EXC(SyntaxError) \ + EXC(SystemError) \ + EXC(TypeError) \ + EXC(ValueError) \ + EXC(Warning) \ + \ + EXC(FloatingPointError) \ + EXC(OverflowError) \ + EXC(ZeroDivisionError) \ + \ + EXC(BytesWarning) \ + EXC(DeprecationWarning) \ + EXC(EncodingWarning) \ + EXC(FutureWarning) \ + EXC(ImportWarning) \ + EXC(PendingDeprecationWarning) \ + EXC(ResourceWarning) \ + EXC(RuntimeWarning) \ + EXC(SyntaxWarning) \ + EXC(UnicodeWarning) \ + EXC(UserWarning) \ + \ + EXC(BlockingIOError) \ + EXC(ChildProcessError) \ + EXC(ConnectionError) \ + EXC(FileExistsError) \ + EXC(FileNotFoundError) \ + EXC(InterruptedError) \ + EXC(IsADirectoryError) \ + EXC(NotADirectoryError) \ + EXC(PermissionError) \ + EXC(ProcessLookupError) \ + EXC(TimeoutError) \ + \ + EXC(IndentationError) \ + EXC(IndexError) \ + EXC(KeyError) \ + EXC(ImportCycleError) \ + EXC(ModuleNotFoundError) \ + EXC(NotImplementedError) \ + EXC(PythonFinalizationError) \ + EXC(RecursionError) \ + EXC(UnboundLocalError) \ + EXC(UnicodeError) \ + \ + EXC(BrokenPipeError) \ + EXC(ConnectionAbortedError) \ + EXC(ConnectionRefusedError) \ + EXC(ConnectionResetError) \ + \ + EXC(TabError) \ + \ + EXC(UnicodeDecodeError) \ + EXC(UnicodeEncodeError) \ + EXC(UnicodeTranslateError) + + +/* Static exceptions whose exposed name differs from the symbol's + suffix after `_PyExc_`. Each entry is (NAME, "exposed name"). */ +#define _Py_FOREACH_RENAMED_EXCEPTION_TYPE(EXC) \ + EXC(IncompleteInputError, "_IncompleteInputError") + + +/* One TYPE(name) per textual _PyStaticType_InitBuiltin / + _PyStructSequence_InitBuiltin{,WithFlags} call site outside the two + arrays above. Count-only -- the calls themselves stay at their + existing locations. Forgetting an entry trips the + `index < _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES` assertion in + Objects/typeobject.c on interpreter start. */ +#define _Py_FOREACH_STATIC_EXTRA_TYPE(TYPE) \ + /* Python/crossinterp_exceptions.h */ \ + TYPE(_PyExc_InterpreterError) \ + TYPE(_PyExc_InterpreterNotFoundError) \ + /* Objects/unicodeobject.c */ \ + TYPE(EncodingMapType) \ + TYPE(PyFieldNameIter_Type) \ + TYPE(PyFormatterIter_Type) \ + /* Python/thread.c */ \ + TYPE(ThreadInfoType) \ + /* Python/sysmodule.c */ \ + TYPE(Hash_InfoType) \ + TYPE(AsyncGenHooksType) \ + TYPE(VersionInfoType) \ + TYPE(FlagsType) \ + TYPE(WindowsVersionType) \ + /* Python/errors.c */ \ + TYPE(UnraisableHookArgsType) \ + /* Objects/longobject.c */ \ + TYPE(Int_InfoType) \ + /* Objects/floatobject.c */ \ + TYPE(FloatInfoType) + + +/* Variadic so it accepts both single-arg X(name) and two-arg X(name, str). */ +#define _PY_COUNT_STATIC_TYPE_(...) + 1 + +#define _Py_NUM_MANAGED_PREINITIALIZED_TYPES \ + (0 _Py_FOREACH_STATIC_PREINIT_TYPE(_PY_COUNT_STATIC_TYPE_)) + +#define _Py_NUM_MANAGED_STATIC_EXCEPTION_TYPES \ + (0 _Py_FOREACH_STATIC_EXCEPTION_TYPE(_PY_COUNT_STATIC_TYPE_) \ + _Py_FOREACH_RENAMED_EXCEPTION_TYPE(_PY_COUNT_STATIC_TYPE_)) + +#define _Py_NUM_MANAGED_STATIC_EXTRA_TYPES \ + (0 _Py_FOREACH_STATIC_EXTRA_TYPE(_PY_COUNT_STATIC_TYPE_)) + +#define _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES \ + (_Py_NUM_MANAGED_PREINITIALIZED_TYPES + \ + _Py_NUM_MANAGED_STATIC_EXCEPTION_TYPES + \ + _Py_NUM_MANAGED_STATIC_EXTRA_TYPES) + +#define _Py_MAX_MANAGED_STATIC_EXT_TYPES 10 + +#define _Py_MAX_MANAGED_STATIC_TYPES \ + (_Py_MAX_MANAGED_STATIC_BUILTIN_TYPES + _Py_MAX_MANAGED_STATIC_EXT_TYPES) + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_STATIC_BUILTIN_TYPES_H */ diff --git a/Makefile.pre.in b/Makefile.pre.in index 2b34b009fd745a..bf5f79a6cf36bd 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1399,6 +1399,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_sliceobject.h \ $(srcdir)/Include/internal/pycore_slots.h \ $(srcdir)/Include/internal/pycore_slots_generated.h \ + $(srcdir)/Include/internal/pycore_static_builtin_types.h \ $(srcdir)/Include/internal/pycore_stats.h \ $(srcdir)/Include/internal/pycore_strhex.h \ $(srcdir)/Include/internal/pycore_stackref.h \ diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-17-02-39.gh-issue-145497.FPE2LI.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-17-02-39.gh-issue-145497.FPE2LI.rst new file mode 100644 index 00000000000000..57adf3f5488fb8 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-17-02-39.gh-issue-145497.FPE2LI.rst @@ -0,0 +1 @@ +Compute static builtin type count at compile time. Patch by Donghee Na. diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 34a7844c857732..2b8f69be219150 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -4393,97 +4393,12 @@ struct static_exception { }; static struct static_exception static_exceptions[] = { -#define ITEM(NAME) {&_PyExc_##NAME, #NAME} - // Level 1 - ITEM(BaseException), - - // Level 2: BaseException subclasses - ITEM(BaseExceptionGroup), - ITEM(Exception), - ITEM(GeneratorExit), - ITEM(KeyboardInterrupt), - ITEM(SystemExit), - - // Level 3: Exception(BaseException) subclasses - ITEM(ArithmeticError), - ITEM(AssertionError), - ITEM(AttributeError), - ITEM(BufferError), - ITEM(EOFError), - //ITEM(ExceptionGroup), - ITEM(ImportError), - ITEM(LookupError), - ITEM(MemoryError), - ITEM(NameError), - ITEM(OSError), - ITEM(ReferenceError), - ITEM(RuntimeError), - ITEM(StopAsyncIteration), - ITEM(StopIteration), - ITEM(SyntaxError), - ITEM(SystemError), - ITEM(TypeError), - ITEM(ValueError), - ITEM(Warning), - - // Level 4: ArithmeticError(Exception) subclasses - ITEM(FloatingPointError), - ITEM(OverflowError), - ITEM(ZeroDivisionError), - - // Level 4: Warning(Exception) subclasses - ITEM(BytesWarning), - ITEM(DeprecationWarning), - ITEM(EncodingWarning), - ITEM(FutureWarning), - ITEM(ImportWarning), - ITEM(PendingDeprecationWarning), - ITEM(ResourceWarning), - ITEM(RuntimeWarning), - ITEM(SyntaxWarning), - ITEM(UnicodeWarning), - ITEM(UserWarning), - - // Level 4: OSError(Exception) subclasses - ITEM(BlockingIOError), - ITEM(ChildProcessError), - ITEM(ConnectionError), - ITEM(FileExistsError), - ITEM(FileNotFoundError), - ITEM(InterruptedError), - ITEM(IsADirectoryError), - ITEM(NotADirectoryError), - ITEM(PermissionError), - ITEM(ProcessLookupError), - ITEM(TimeoutError), - - // Level 4: Other subclasses - ITEM(IndentationError), // base: SyntaxError(Exception) - {&_PyExc_IncompleteInputError, "_IncompleteInputError"}, // base: SyntaxError(Exception) - ITEM(IndexError), // base: LookupError(Exception) - ITEM(KeyError), // base: LookupError(Exception) - ITEM(ImportCycleError), // base: ImportError(Exception) - ITEM(ModuleNotFoundError), // base: ImportError(Exception) - ITEM(NotImplementedError), // base: RuntimeError(Exception) - ITEM(PythonFinalizationError), // base: RuntimeError(Exception) - ITEM(RecursionError), // base: RuntimeError(Exception) - ITEM(UnboundLocalError), // base: NameError(Exception) - ITEM(UnicodeError), // base: ValueError(Exception) - - // Level 5: ConnectionError(OSError) subclasses - ITEM(BrokenPipeError), - ITEM(ConnectionAbortedError), - ITEM(ConnectionRefusedError), - ITEM(ConnectionResetError), - - // Level 5: IndentationError(SyntaxError) subclasses - ITEM(TabError), // base: IndentationError - - // Level 5: UnicodeError(ValueError) subclasses - ITEM(UnicodeDecodeError), - ITEM(UnicodeEncodeError), - ITEM(UnicodeTranslateError), +#define ITEM(NAME) {&_PyExc_##NAME, #NAME}, +#define ITEM_RENAMED(NAME, STR) {&_PyExc_##NAME, STR}, + _Py_FOREACH_STATIC_EXCEPTION_TYPE(ITEM) + _Py_FOREACH_RENAMED_EXCEPTION_TYPE(ITEM_RENAMED) #undef ITEM +#undef ITEM_RENAMED }; diff --git a/Objects/object.c b/Objects/object.c index e0e26bb50d3653..9e13365720f3c5 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -2526,143 +2526,11 @@ extern PyTypeObject _PyMemoryIter_Type; extern PyTypeObject _PyPositionsIterator; extern PyTypeObject _Py_GenericAliasIterType; -static PyTypeObject* static_types[_Py_NUM_MANAGED_PREINITIALIZED_TYPES] = { - // The two most important base types: must be initialized first and - // deallocated last. - &PyBaseObject_Type, - &PyType_Type, - - // PyStaticMethod_Type and PyCFunction_Type are used by PyType_Ready() - // on other types and so must be initialized first. - &PyStaticMethod_Type, - &PyCFunction_Type, - - // Static types with base=&PyBaseObject_Type - &PyAsyncGen_Type, - &PyByteArrayIter_Type, - &PyByteArray_Type, - &PyBytesIter_Type, - &PyBytes_Type, - &PyCallIter_Type, - &PyCapsule_Type, - &PyCell_Type, - &PyClassMethodDescr_Type, - &PyClassMethod_Type, - &PyCode_Type, - &PyComplex_Type, - &PyContextToken_Type, - &PyContextVar_Type, - &PyContext_Type, - &PyCoro_Type, - &PyDictItems_Type, - &PyDictIterItem_Type, - &PyDictIterKey_Type, - &PyDictIterValue_Type, - &PyDictKeys_Type, - &PyDictProxy_Type, - &PyDictRevIterItem_Type, - &PyDictRevIterKey_Type, - &PyDictRevIterValue_Type, - &PyDictValues_Type, - &PyDict_Type, - &PyEllipsis_Type, - &PyEnum_Type, - &PyFilter_Type, - &PyFloat_Type, - &PyFrameLocalsProxy_Type, - &PyFrame_Type, - &PyFrozenDict_Type, - &PyFrozenSet_Type, - &PyFunction_Type, - &PyGen_Type, - &PyGetSetDescr_Type, - &PyInstanceMethod_Type, - &PyLazyImport_Type, - &PyListIter_Type, - &PyListRevIter_Type, - &PyList_Type, - &PyLongRangeIter_Type, - &PyLong_Type, - &PyMap_Type, - &PyMemberDescr_Type, - &PyMemoryView_Type, - &PyMethodDescr_Type, - &PyMethod_Type, - &PyModuleDef_Type, - &PyModule_Type, - &PyODictIter_Type, - &PyPickleBuffer_Type, - &PyProperty_Type, - &PyRangeIter_Type, - &PyRange_Type, - &PyReversed_Type, - &PySTEntry_Type, - &PySentinel_Type, - &PySeqIter_Type, - &PySetIter_Type, - &PySet_Type, - &PySlice_Type, - &PyStdPrinter_Type, - &PySuper_Type, - &PyTraceBack_Type, - &PyTupleIter_Type, - &PyTuple_Type, - &PyUnicodeIter_Type, - &PyUnicode_Type, - &PyWrapperDescr_Type, - &PyZip_Type, - &Py_GenericAliasType, - &_PyAnextAwaitable_Type, - &_PyAsyncGenASend_Type, - &_PyAsyncGenAThrow_Type, - &_PyAsyncGenWrappedValue_Type, - &_PyBufferWrapper_Type, - &_PyContextTokenMissing_Type, - &_PyCoroWrapper_Type, - &_Py_GenericAliasIterType, - &_PyHamtItems_Type, - &_PyHamtKeys_Type, - &_PyHamtValues_Type, - &_PyHamt_ArrayNode_Type, - &_PyHamt_BitmapNode_Type, - &_PyHamt_CollisionNode_Type, - &_PyHamt_Type, - &_PyInstructionSequence_Type, - &_PyInterpolation_Type, - &_PyLegacyEventHandler_Type, - &_PyLineIterator, - &_PyManagedBuffer_Type, - &_PyMemoryIter_Type, - &_PyMethodWrapper_Type, - &_PyNamespace_Type, - &_PyNone_Type, - &_PyNotImplemented_Type, - &_PyPositionsIterator, - &_PyTemplate_Type, - &_PyTemplateIter_Type, - &_PyUnicodeASCIIIter_Type, - &_PyUnion_Type, -#ifdef _Py_TIER2 - &_PyUOpExecutor_Type, -#else - // The array should have the same size on all builds; see gh-149139 - NULL, -#endif - &_PyWeakref_CallableProxyType, - &_PyWeakref_ProxyType, - &_PyWeakref_RefType, - &_PyTypeAlias_Type, - &_PyNoDefault_Type, - - // subclasses: _PyTypes_FiniTypes() deallocates them before their base - // class - &PyBool_Type, // base=&PyLong_Type - &PyCMethod_Type, // base=&PyCFunction_Type - &PyODictItems_Type, // base=&PyDictItems_Type - &PyODictKeys_Type, // base=&PyDictKeys_Type - &PyODictValues_Type, // base=&PyDictValues_Type - &PyODict_Type, // base=&PyDict_Type +#define _ADD_TYPE(name) &name, +static PyTypeObject* static_types[] = { + _Py_FOREACH_STATIC_PREINIT_TYPE(_ADD_TYPE) }; +#undef _ADD_TYPE PyStatus @@ -2671,9 +2539,6 @@ _PyTypes_InitTypes(PyInterpreterState *interp) // All other static types (unless initialized elsewhere) for (size_t i=0; i < Py_ARRAY_LENGTH(static_types); i++) { PyTypeObject *type = static_types[i]; - if (type == NULL) { - continue; - } if (_PyStaticType_InitBuiltin(interp, type) < 0) { return _PyStatus_ERR("Can't initialize builtin type"); } @@ -2714,9 +2579,6 @@ _PyTypes_FiniTypes(PyInterpreterState *interp) // their base classes. for (Py_ssize_t i=Py_ARRAY_LENGTH(static_types)-1; i>=0; i--) { PyTypeObject *type = static_types[i]; - if (type == NULL) { - continue; - } _PyStaticType_FiniBuiltin(interp, type); } } diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index e255ed5af19125..89f0ddbc03015a 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -319,6 +319,7 @@ + diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 649ee1859ff996..3f3dedd7831119 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -858,6 +858,9 @@ Include\internal + + Include\internal + Include\internal