Skip to content

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

Open
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:test_clear
Open

gh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL#157067
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:test_clear

Conversation

@vstinner

@vstinner vstinner commented Sep 7, 2026

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().

* 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 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.

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

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

Labels

awaiting core review needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news topic-C-API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant