← 输入框|github.com|刷新
Skip to content

Adjust _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES value automatically #145497

Open

Description

@corona10

When a new built-in type is introduced, _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES needs to be updated accordingly.
(e.g., 3e2f5c1, #145496 (comment))

This is quite painful, and sometimes we even forget to adjust it. To prevent this kind of issue, we may need a way to update it automatically, or add a test that verifies it is set correctly.

cc @markshannon @Fidget-Spinner @vstinner

Linked PRs

Activity

  1. vstinner commented on Mar 4, 2026

    @vstinner
    Member

    How do you want to compute _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES value?

    The static_types array in Objects/object.c only has 118 entries (where _PyUOpExecutor_Type is only available if _Py_TIER2 macro is defined), whereas _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES is equal to 201 (it should be 202, PR gh-145496 fix it). So I don't see the direct relationship between static_types and _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES.

  2. corona10 commented on Mar 4, 2026

    @corona10
    MemberAuthor

    How do you want to compute _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES value?

    I don't think about it concretely, but I believe that we need to find a better way.

  3. added
    interpreter-core
    type-feature
    on Mar 5, 2026
  4. self-assigned this
    on Mar 5, 2026
  5. ZeroIntensity commented on Apr 29, 2026

    @ZeroIntensity
    Member

    Another example of this causing issues: #149121. At the very least, it would be nice to have a test that verified the number, so we don't run into weird issues on the main branch when we forget to fix it.

    So I don't see the direct relationship between static_types and _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES.

    Hm, what is _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES if not the length of static_types? Where do the other ~80 entries come from?

  6. JelleZijlstra commented on Apr 29, 2026

    @JelleZijlstra
    Member

    Seems the rest are mostly exception classes and a few others that aren't in static_types itself.

    Here's a list from printing every type that gets added:

    static.txt

  7. encukou commented on Apr 29, 2026

    @encukou
    Member

    See also #149121.

  8. added a commit that references this issue on May 1, 2026
  9. StanFromIreland commented on May 2, 2026

    @StanFromIreland
    Member

    Triage: with #149139 merged, can this be closed?

  10. StanFromIreland commented on May 2, 2026

    @StanFromIreland
    Member

    Ooops wrong button.

  11. added
    pending
    on May 2, 2026
  12. corona10 commented on May 2, 2026

    @corona10
    MemberAuthor

    Yes we can close! Thank you @encukou

  13. encukou commented on May 4, 2026

    @encukou
    Member

    Sadly, that PR is just a workaround. It would still be nice to adjust this automatically.

  14. reopened this on May 4, 2026
  15. removed
    pending
    on May 4, 2026
  16. added 2 commits that reference this issue on Sep 15, 2026
  17. vstinner commented on Sep 15, 2026

    @vstinner
    Member

    Please see my new PR gh-157582 which actually counts static types at Python startup (in debug mode) to make sure that macros are still up to date.

  18. vstinner commented on Nov 15, 2026

    @vstinner
    Member

    On PR gh-161455, ERROR: test_pytype_ready_always_sets_tp_type (test.test_capi.test_misc.TestStaticTypes.test_pytype_ready_always_sets_tp_type) fails on iOS with RuntimeError: no more available basic static types. I suppose that it's related to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-coretopic-C-APItype-feature

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions