Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion Include/internal/pycore_interp_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,49 @@ struct _py_func_state {

/****** type state *********/

/* One TYPE(name) per textual _PyStaticType_InitBuiltin /
_PyStructSequence_InitBuiltin{,WithFlags} call site outside the static_types
and static_exceptions arrays. 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)

#define _PY_COUNT_STATIC_TYPE_(name) + 1
#define _Py_NUM_MANAGED_STATIC_EXTRA_TYPES \
(0 _Py_FOREACH_STATIC_EXTRA_TYPE(_PY_COUNT_STATIC_TYPE_))

/* 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still _Py_NUM_MANAGED_PREINITIALIZED_TYPES is manged by hand.

#define _Py_NUM_STATIC_EXCEPTIONS 69

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you mange the number of _Py_NUM_STATIC_EXCEPTIONS manually, I beleive that this is not what we wanted

#define _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES \
(_Py_NUM_MANAGED_PREINITIALIZED_TYPES + 83)
(_Py_NUM_MANAGED_PREINITIALIZED_TYPES + _Py_NUM_STATIC_EXCEPTIONS \
+ _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)
Expand Down
2 changes: 1 addition & 1 deletion Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -4392,7 +4392,7 @@ struct static_exception {
const char *name;
};

static struct static_exception static_exceptions[] = {
static struct static_exception static_exceptions[_Py_NUM_STATIC_EXCEPTIONS] = {
#define ITEM(NAME) {&_PyExc_##NAME, #NAME}
// Level 1
ITEM(BaseException),
Expand Down
Loading