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 — [WIP] bpo-42294: Add Py_SetRef() and Py_XSetRef() by vstinner · Pull Request #23209 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Nov 9, 2020 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Add Py_SetRef() and Py_XSetRef() functions to set a strong reference
to a new object without creating a temporary dangling pointer.

Rewrite the Py_SETREF() and Py_XSETREF() macros using respectively
Py_SetRef() and Py_XSetRef() functions.

Rewrite the Py_CLEAR() macro using the Py_XSetRef() public.

https://bugs.python.org/issue42294

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner
bpo-42294: Add Py_SetRef() and Py_XSetRef()
6cdeb38
Add Py_SetRef() and Py_XSetRef() functions to set a strong reference
to a new object without creating a temporary dangling pointer.

Rewrite the Py_SETREF() and Py_XSETREF() macros using respectively
Py_SetRef() and Py_XSetRef() functions.

Rewrite the Py_CLEAR() macro using the Py_XSetRef() public.
@vstinner
vstinner requested a review from a team as a code owner November 9, 2020 14:19
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Nov 9, 2020
@bedevere-bot bedevere-bot added the awaiting core review label Nov 9, 2020
@vstinner

vstinner commented Nov 9, 2020 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

This change exposes Py_SETREF() and Py_XSETREF() macros as regular functions to allow using them in extension modules which cannot use the C preprocessor, like extensions written in Rust. It also adds Py_SetRef() and Py_XSetRef() as regular functions part of the limited C API and the stable ABI, whereas Py_SETREF() and Py_XSETREF() are excluded from the limited C API.

The Py_SETREF() and Py_XSETREF() macros were added in 2016 by @serhiy-storchaka in bpo-26200 with the commit 57a01d3.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
Fix typo in the doc
590e4ac
@vstinner

vstinner commented Nov 9, 2020

Copy link
Copy Markdown
Member Author

cc @methane @serhiy-storchaka

All reactions

Sorry, something went wrong.

Uh oh!

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

@methane

methane commented Nov 10, 2020

Copy link
Copy Markdown
Member

I am not sure about this change really helps Rust, PyPy, HPy, etc.
Is this proposal based on some discussion in some forum?

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner changed the title bpo-42294: Add Py_SetRef() and Py_XSetRef() [WIP] bpo-42294: Add Py_SetRef() and Py_XSetRef() Nov 11, 2020
@vstinner
vstinner marked this pull request as draft November 11, 2020 00:46
@vstinner

vstinner commented Nov 11, 2020

Copy link
Copy Markdown
Member Author

I am not sure about this change really helps Rust, PyPy, HPy, etc.
Is this proposal based on some discussion in some forum?

There was no discussion about that. I prefer to convert this PR to a draft until I have more time to explain the overall rationale for https://bugs.python.org/issue42294

Also, Serhiy wrote that Py_SETREF() had some flaws, I didn't know that. I will have to dig into old discussions.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions

github-actions Bot commented Dec 16, 2020

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Dec 16, 2020
@vstinner vstinner removed the stale Stale PR or inactive for long period of time. label Dec 16, 2020
@github-actions

github-actions Bot commented Jan 15, 2021

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jan 15, 2021
@vstinner

vstinner commented Mar 17, 2021

Copy link
Copy Markdown
Member Author

I close this PR since I failed to prove that it's useful for Rust, PyPy or HPy.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner closed this Mar 17, 2021
@vstinner
vstinner deleted the setref branch March 17, 2021 20:53
@vstinner vstinner mentioned this pull request May 11, 2023
Macro Py_CLEAR references argument two times. #98724
Closed
@vstinner vstinner mentioned this pull request Jul 9, 2023
[C API] Add new C functions with more regular reference counting like PyTuple_GetItemRef() #86460
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

awaiting core review stale Stale PR or inactive for long period of time.

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.

4 participants

@vstinner @methane @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.