GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Cannot include `cpython/Include/internal/pycore_optimizer.h` in C++ extension due to use of protected C++ keyword "not" · Issue #131331 · python/cpython

Cannot include cpython/Include/internal/pycore_optimizer.h in C++ extension due to use of protected C++ keyword "not" #131331

New issue
Copy link
New issue
Copy link
Closed
Closed
Cannot include cpython/Include/internal/pycore_optimizer.h in C++ extension due to use of protected C++ keyword "not"#131331
Copy link
Assignees
picnixz
Labels
3.14bugs and security fixesbugs and security fixesbuildThe build process and cross-buildThe build process and cross-buildinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@tim-stephenson
tim-stephenson
opened on Mar 16, 2025
Issue body actions

Bug report

Bug description:

The code in cpython/Include/internal/pycore_optimizer.h causing problems

typedef struct {
    uint8_t tag;
    bool not;
    uint16_t value;
} JitOptTruthiness;
  • PR which created the issue: GH-130415: Use boolean guards to narrow types to values in the JIT #130659

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

  • gh-131331: rename not field to invert for C++ extension modules #131334

Activity

  1. tim-stephenson
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Mar 16, 2025
  2. tim-stephenson commented on Mar 16, 2025

    @tim-stephenson
    tim-stephenson
    on Mar 16, 2025
    Author
    More actions

    My understanding is that there is no good way around this for C++ extensions: https://stackoverflow.com/questions/72177535/how-can-i-include-a-c-header-that-uses-a-c-keyword-as-an-identifier-in-c

  3. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    buildThe build process and cross-buildThe build process and cross-build
    on Mar 16, 2025
  4. picnixz commented on Mar 16, 2025

    @picnixz
    picnixz
    on Mar 16, 2025
    Member
    More actions

    AFAIK, cpython/Include/internal/pycore_optimizer.h is not meant to be included directly, nor from an extension module as it's internal. Is there an issue because of some indirect includes if one uses #include "Python.h"? or is this only caused when one tries to include that specific header?

    EDIT: I'm marking it as a release blocker if this implies that C++ extensions cannot be built anymore but if it's because of internal includes, then we can remove the label.

  5. picnixz
    added
    release-blocker
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Mar 16, 2025
  6. ezio-melotti
    added this to Release and Deferred blockers 🚫on Mar 16, 2025
  7. github-project-automation
    moved this to Todo in Release and Deferred blockers 🚫on Mar 16, 2025
  8. picnixz commented on Mar 16, 2025

    @picnixz
    picnixz
    on Mar 16, 2025
    Member
    More actions

    cc @brandtbucher

  9. tim-stephenson commented on Mar 16, 2025

    @tim-stephenson
    tim-stephenson
    on Mar 16, 2025
    Author
    More actions

    The use is here: https://github.com/numba/numba/blob/main/numba/_dispatcher.cpp. The explanation to why they are using internal includes is https://github.com/numba/numba/blob/d650f3057839f99a0ab77262f27e80f4b9ae6739/numba/_dispatcher.cpp#L811

  10. picnixz
    added
    topic-JIT
    and removed
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Mar 16, 2025
  11. picnixz commented on Mar 16, 2025

    @picnixz
    picnixz
    on Mar 16, 2025
    Member
    More actions

    I think it doesn't hurt on our side if just use something else than not. We can use not_. I'll make a PR for that.

    EDIT: However, I would like to mention that using internal headers is at one's own risk, though, in this case, the fix on our side is easy.

    Reacted by Petr Viktorin
  12. picnixz
    self-assigned this
    on Mar 16, 2025
  13. encukou
    removed
    release-blocker
    on Mar 17, 2025
  14. markshannon commented on Mar 18, 2025

    @markshannon
    markshannon
    on Mar 18, 2025
    Member
    More actions

    I would argue that allowing internal headers to be accessed in third-party code does hurt us.
    Accessing the internals without a clear understanding of the necessary invariants can leave the VM in a broken state.
    The resulting issues can be hard to debug and can consume of a lot of our time.

    Regarding the numba issue. If there is a feature that is needed but does not have a public API, then we need to tell extension developers to submit a feature request, like this one from the Cython developers.

  15. picnixz commented on Mar 18, 2025

    @picnixz
    picnixz
    on Mar 18, 2025
    Member
    More actions

    I would argue that allowing internal headers to be accessed in third-party code does hurt us.

    Yes, in general, that's what I would say. But if the fix is simple enough and if it's easier than to make a feature request, then I'd say let's do it on our side. But I agree that I would prefer not to worry about compatibilty with projects including internal headers.

    Would you be willing to consider accepting my fix for this specific issue though?

  16. picnixz
    removed this from Release and Deferred blockers 🚫on Mar 19, 2025
  17. picnixz
    added
    3.14bugs and security fixesbugs and security fixes
    on Mar 19, 2025
  18. brandtbucher
    added a commit that references this issue on Mar 20, 2025

    GH-131331: Rename "not" to "invert" (GH-131334)

    883c2f6
  19. brandtbucher
    closed this as completedon Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @picnixz
    picnixz

Labels

3.14bugs and security fixesbugs and security fixesbuildThe build process and cross-buildThe build process and cross-buildinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.