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 — code.h uses MS-only C++ extensions · Issue #101907 · python/cpython

code.h uses MS-only C++ extensions #101907

New issue
Copy link
New issue
Copy link
Closed
Closed
code.h uses MS-only C++ extensions#101907
Copy link
Labels
3.12only security fixesonly security fixesbuildThe build process and cross-buildThe build process and cross-build

Description

@zooba
zooba
opened on Feb 14, 2023
Issue body actions

Issue #100222 added a struct to Include/cpython/code.h (which is included by default by Python.h) that is not compliant C++:

typedef union {
    uint16_t cache;
    struct {
        uint8_t opcode;
        uint8_t oparg;
    };
} _Py_CODEUNIT;

The struct member requires a name, as only anonymous structs are currently permitted in standard C++.

(And since the original issue invokes PEP 7, I'll do the same and point out that "The public C API should be compatible with C++". The intention of this clause is that standard C++ can #include <Python.h>, which is currently broken.)

Linked PRs

  • gh-101907: Removes use of non-standard C++ extension from Include/cpython/code.h #101909
  • gh-101907: Stop using _Py_OPCODE and _Py_OPARG macros #101912

Activity

  1. zooba
    added
    buildThe build process and cross-buildThe build process and cross-build
    3.12only security fixesonly security fixes
    on Feb 14, 2023
  2. zooba
    added a commit that references this issue on Feb 14, 2023

    pythongh-101907: Removes use of non-standard C++ extension from Inclu…

    1f5d7cb
  3. markshannon commented on Feb 14, 2023

    @markshannon
    markshannon
    on Feb 14, 2023
    Member
    More actions

    Rather than replace all the .opcode and .oparg with SHOUTY MACROS, how about:

    typedef union {
        uint16_t cache;
        struct {
            uint8_t code;
            uint8_t arg;
        } op;
    } _Py_CODEUNIT;
    

    Then i.oparg becomes i.op.arg which is still readable.

  4. zooba commented on Feb 14, 2023

    @zooba
    zooba
    on Feb 14, 2023
    MemberAuthor
    More actions

    Do we want that to be the API then? And so we should remove the macros entirely?

    If we're going to have macros, I'd rather they be the only place we have to make a change like this.

  5. markshannon commented on Feb 14, 2023

    @markshannon
    markshannon
    on Feb 14, 2023
    Member
    More actions

    Personally, I'd say get rid of the macros.

    At least the uses of them. We should probably keep the declarations in case any third-party code is using them.

  6. zooba
    added a commit that references this issue on Feb 14, 2023

    Merge remote-tracking branch 'cpython/main' into pythongh-101907-2

    5edc4d4
  7. markshannon
    added a commit that references this issue on Feb 20, 2023

    gh-101907: Stop using `_Py_OPCODE` and `_Py_OPARG` macros (GH-101912)

    a99eb5c
  8. zooba
    closed this as completedon Feb 20, 2023
  9. jaraco
    added a commit that references this issue on Feb 20, 2023

    pythongh-101907: Stop using `_Py_OPCODE` and `_Py_OPARG` macros (pyth…

    ca5d36e
  10. carljm
    added 2 commits that reference this issue on Feb 20, 2023

    Merge branch 'main' into inlinecomp2

    9f0fc5b

    Merge branch 'main' into inlinecomp

    544b30c
  11. python-sidebar
    added 2 commits that reference this issue on Sep 1, 2024

    pythongh-101907: Stop using `_Py_OPCODE` and `_Py_OPARG` macros (pyth…

    193d39f

    pythongh-101907: Stop using `_Py_OPCODE` and `_Py_OPARG` macros (pyth…

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesonly security fixesbuildThe build process and cross-buildThe build process and cross-build

    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.