FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-145497: Fix _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES by vstinner · Pull Request #151152 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .h  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
37 changes: 36 additions & 1 deletion Include/internal/pycore_interp_structs.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL