| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -535,12 +535,15 @@ struct _py_func_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 | ||
| If you add a new static type or exception to the standard library, you must | ||
| update one of these numbers. | ||
| */ | ||
| #define _Py_NUM_MANAGED_PREINITIALIZED_TYPES 122 | ||
| #define _Py_NUM_MANAGED_PREINITIALIZED_TYPES 121 | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySo why the number of _Py_NUM_MANAGED_PREINITIALIZED_TYPES is decreased to 121?, it still needs to pay attention each number :(
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityBetter way would be we don't need to designate the specific number but just register types into some place.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
A built-in type has been removed recently. When the type was removed, the constant was not updated. This PR detected that the constant is outdated, so I updated it.
The number of static types and the number of static exceptions can be exported, my PR does exactly that in debug mode. But I don't see how to get the number of "static extra type" at build time. It would require a script to look for all built-in types and then exclude static types and static exceptions. It sounds complicated to do. Counting types at runtime in _PyStaticType_InitForExtension() and _PyStaticType_InitBuiltin() as does my PR looks more reliable to me, since all static types call these functions. Adding or removing a type or exception is an uncommon operation, so I don't think that we need a too elaborated check for these. IMO this PR is good enough to solve the problem: detect when a constant is outdated.
Sorry, something went wrong.
All reactions
|
||
| #define _Py_NUM_MANAGED_STATIC_EXTRA_TYPES 14 | ||
| #define _Py_NUM_STATIC_EXCEPTIONS 69 | ||
| #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 | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
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 QualityI think this needs to be wrapped in #ifdef Py_DEBUG as well.
Also, why is this in the header file in the first place? Why not just define it in exceptions.c?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 QualityThis type is also used in release mode by Objects/exceptions.c.
The PR adds count_static_types() in Objects/typeobject.c which does access to extern struct static_exception *_Py_static_exceptions;: it has to know the structure members. Extract:
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 QualityOh, I missed that it was an existing type. Can we rename it to _Py_static_exception or something like that? It's generally uncommon for our header files to expose names that aren't prefixed with _Py.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.