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 — bpo-39573: Py_TYPE becomes a static inline function by vstinner · Pull Request #26493 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jun 2, 2021 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Convert the Py_TYPE() and Py_SIZE() macros to static inline
functions. The Py_SET_TYPE() and Py_SET_SIZE() functions must now be
used to set an object type and size.

https://bugs.python.org/issue39573

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@vstinner
bpo-39573: Py_TYPE becomes a static inline function
a379611
Convert the Py_TYPE() and Py_SIZE() macros to static inline
functions. The Py_SET_TYPE() and Py_SET_SIZE() functions must now be
used to set an object type and size.
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Jun 2, 2021
@bedevere-bot bedevere-bot added the awaiting core review label Jun 2, 2021
@vstinner

vstinner commented Jun 2, 2021

Copy link
Copy Markdown
Member Author

One year ago, I already pushed the same change to Python 3.10, but it broke many projects and so had to be reverted, see: https://bugs.python.org/issue39573#msg370074

Multiple things changed since my latest attempt:

  • Major projects like Cython and numpy have been prepared for this incompatible change

  • I created the https://github.com/pythoncapi/pythoncapi_compat project which is made of two parts:

    • pythoncapi_compat.h header file provides Py_SET_TYPE() and Py_SET_TYPE() to old Python versions: it supports Python 2.7-3.11.
    • upgrade_pythoncapi.py script automates the migration of existing C extensions to the new API (Py_SET_TYPE, Py_SET_TYPE) without losing support with Python 2.7-3.8.
  • pythoncapi_compat.h header and upgrade_pythoncapi.py script have been used successfully on multiple projects (bitarray, immutables, Mercurial, python-zstandard). These projects now include a copy of pythoncapi_compat.h to support old Python versions.

Note: C extensions implemented with Cython only have to regenerate the C files using Cython, if it's not already done (Cython was fixed one year ago).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 2, 2021

Copy link
Copy Markdown
Member Author

More info about the pythoncapi_compat project: https://vstinner.github.io/pythoncapi_compat.html

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 3, 2021

Copy link
Copy Markdown
Member Author

The previous attempt (reverted change) was: #20290

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner merged commit f3fa63e into python:main Jun 3, 2021
@bedevere-bot bedevere-bot removed the awaiting core review label Jun 3, 2021
@vstinner
vstinner deleted the py_type branch June 3, 2021 16:43
@vstinner

vstinner commented Jun 3, 2021

Copy link
Copy Markdown
Member Author

I prefer to merge such incompatible change early in 3.11 dev cycle to give more test to users to test it. If things go wild again, we can consider to revert it a second time.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal added a commit to pablogsal/cpython that referenced this pull request Jun 8, 2021
@pablogsal
bpo-44348: Revert "bpo-39573: Py_TYPE becomes a static inline function (
9737fa5
pythonGH-26493)"

This reverts commit f3fa63e as is
causing crashes in some Windows tests in the buildbots.
pablogsal added a commit that referenced this pull request Jun 8, 2021
@pablogsal
bpo-44348: Revert "bpo-39573: Py_TYPE becomes a static inline function (
6d518bb
GH-26493)" (GH-26596)

This reverts commit f3fa63e as is
causing crashes in some Windows tests in the buildbots.
@vstinner vstinner mentioned this pull request Mar 12, 2024
[C API] Avoid accessing PyObject and PyVarObject members directly: add Py_SET_TYPE() and Py_IS_TYPE(), disallow Py_TYPE(obj)=type #83754
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@vstinner @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.