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 — gh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL by vstinner · Pull Request #157067 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Sep 7, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Enhance Py_CLEAR() test in test_cext and test_cppext. Check that Py_CLEAR(obj) sets obj to NULL.
  • Add also tests on Py_SETREF() and Py_BEGIN_CRITICAL_SECTION().
  • Issue: memcpy() usage without #include <string.h> in pwdmodule.c #121617

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner
pythongh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL
db2d833
* Enhance Py_CLEAR() test in test_cext and test_cppext.
  Check that Py_CLEAR(obj) sets obj to NULL.
* Add also tests on Py_SETREF() and Py_BEGIN_CRITICAL_SECTION().
@vstinner vstinner added topic-C-API needs backport to 3.15 bugs and security fixes labels Sep 7, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Sep 7, 2026
memcpy() usage without #include <string.h> in pwdmodule.c #121617
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 7, 2026
@vstinner

vstinner commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

This change should be backported to 3.13 and 3.14 branches, but Py_CLEAR() is not tested in these branches. So the change should be backported manually.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner added the skip news label Sep 7, 2026
@vstinner

vstinner commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

At the beginning, I just wanted to check that Py_CLEAR(obj) sets obj to NULL. But I got compiler warnings/errors when I added a test on Py_CLEAR() in test_cppext. So the change became a fix for C++.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner merged commit 36c7440 into python:main Sep 8, 2026
59 checks passed

Uh oh!

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

@vstinner
vstinner deleted the test_clear branch September 8, 2026 14:11
@miss-islington-app

miss-islington-app Bot commented Sep 8, 2026

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting core review label Sep 8, 2026
@bedevere-app

bedevere-app Bot commented Sep 8, 2026

Copy link
Copy Markdown

GH-157186 is a backport of this pull request to the 3.15 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Sep 8, 2026
@bedevere-app

bedevere-app Bot commented Sep 8, 2026

Copy link
Copy Markdown

GH-157187 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

vstinner added a commit to vstinner/cpython that referenced this pull request Sep 8, 2026
@vstinner
pythongh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (p…
b45266b
…ython#157067)

* Enhance Py_CLEAR() test in test_cext and test_cppext.
  Check that Py_CLEAR(obj) sets obj to NULL.
* Add also tests on Py_SETREF() and Py_BEGIN_CRITICAL_SECTION().

(cherry picked from commit 36c7440)
@bedevere-app

bedevere-app Bot commented Sep 8, 2026

Copy link
Copy Markdown

GH-157189 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Oh no, I forgot to replace NULL with _Py_NULL in the memcpy() implementation of Py_CLEAR(): I wrote PR gh-157188 for that. I included this second fix in 3.15, 3.14 and 3.13 backports directly.

All reactions

Sorry, something went wrong.

Uh oh!

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

vstinner added a commit that referenced this pull request Sep 8, 2026
@vstinner
[3.14] gh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (#…
89926c6
…157067) (#157187)

* gh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (#157067)

* Enhance Py_CLEAR() test in test_cext and test_cppext.
  Check that Py_CLEAR(obj) sets obj to NULL.
* Add also tests on Py_SETREF() and Py_BEGIN_CRITICAL_SECTION().

(cherry picked from commit 36c7440)

* Use also _Py_NULL in memcpy() implementation of Py_CLEAR()
vstinner added a commit that referenced this pull request Sep 8, 2026
@vstinner
[3.13] gh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (#…
a4ab2c1
…157067) (#157189)

gh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (#157067)

* Enhance Py_CLEAR() test in test_cext and test_cppext.
  Check that Py_CLEAR(obj) sets obj to NULL.
* Add also tests on Py_SETREF() and Py_BEGIN_CRITICAL_SECTION().

(cherry picked from commit 36c7440)
maurycy added a commit to maurycy/cpython that referenced this pull request Sep 10, 2026
@maurycy
Merge branch 'main' into tachyon-native-callable
e028ff5
* main: (158 commits)
  pythongh-156924: Try reifying lazy imports in `ForwarRef.evaluate()` (python#156940)
  pythongh-156233: Fix typos and code snippet errors in the docs (python#156475)
  pythongh-156837: Refer to yield expressions in generator function definitions (pythonGH-156863)
  pythongh-155292: Skip updating unicodedata with mismatched interpreter (pythonGH-157066)
  pythongh-157170: Document the scope of global curses settings (pythonGH-157207)
  pythongh-155966: Correct handling of `math.tanpi` poles (python#155980)
  pythongh-157170: Restore use_env() after test_use_prescr_screen in test_curses (pythonGH-157171)
  pythongh-156910: fix deadlock in type_set_abstractmethods under free-threading (python#156948)
  pythongh-155648: Write the empty and placeholder IDLE tests (python#156260)
  pythongh-153569: centralize formatted-string state and source spans (python#156484)
  pythongh-157137: Mark the PEP 820 soft deprecations as 3.15, not `next` (python#157138)
  pythongh-152433: Use regular LoadLibrary in UWP for Windows system libs (pythonGH-156972)
  pythongh-121617: Fix Py_CLEAR() memcpy in C++: replace NULL with _Py_NULL (python#157188)
  pythongh-157135: Fix documentation errors in the `math.atan{2}pi` functions (python#157136)
  pythongh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (python#157067)
  pythongh-156774: Speed up pdb startup with asyncio guard (python#156775)
  pythongh-156109: Allow static, non-framework iOS builds (python#156110)
  pythongh-156780: Emscripten: add missing EM_JS_DEPS (python#156798)
  pythongh-152936: Make privileged functions available on Android (python#152977)
  pythongh-123018: Keep the libedit history file header when truncating (pythonGH-157165)
  ...
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Sep 12, 2026
@vstinner @clin1234
pythongh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (p…
c1c92cf
…ython#157067)

* Enhance Py_CLEAR() test in test_cext and test_cppext.
  Check that Py_CLEAR(obj) sets obj to NULL.
* Add also tests on Py_SETREF() and Py_BEGIN_CRITICAL_SECTION().
johnslavik pushed a commit to johnslavik/cpython that referenced this pull request Sep 14, 2026
@vstinner @johnslavik
pythongh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (p…
38cf6af
…ython#157067)

* Enhance Py_CLEAR() test in test_cext and test_cppext.
  Check that Py_CLEAR(obj) sets obj to NULL.
* Add also tests on Py_SETREF() and Py_BEGIN_CRITICAL_SECTION().
serhiy-storchaka pushed a commit that referenced this pull request Oct 10, 2026
@miss-islington @vstinner
[3.15] gh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (G…
748fea0
…H-157067) (GH-157186)

* Enhance Py_CLEAR() test in test_cext and test_cppext.
  Check that Py_CLEAR(obj) sets obj to NULL.
* Add also tests on Py_SETREF() and Py_BEGIN_CRITICAL_SECTION().
(cherry picked from commit 36c7440)

Co-authored-by: Victor Stinner <[email protected]>
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

skip news topic-C-API

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.

1 participant

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