gh-121617: Include <string.h> for Py_CLEAR() macro#144666
gh-121617: Include <string.h> for Py_CLEAR() macro#144666vstinner merged 4 commits intopython:mainfrom
Conversation
If the _Py_TYPEOF macro is not available, include <string.h> to get memcpy() for the Py_CLEAR() macro. The limited C API version 3.11 and newer doesn't include <string.h> anymore. Add a Py_CLEAR() test in test_cext. Modify also _Py_TYPEOF to use C23 typeof() if available.
|
If this change is merged in the main branch, I will write a backport to the 3.14 branch without the C23 change using |
|
Note: |
|
The documentation also needs an update. (3.14 has the list here.) It's somewhat hard to explain, unfortunately. Is it enough to add something vague like “ |
|
I added the following sentence to the doc:
I'm not sure if it's worth it to document this corner case. |
|
It looks hard to explain. Is it a good idea? Looking more into this, I see
Plus, I think we want to be able to use I think we should go ahead and always include |
Ok, let's do that. |
|
🤖 New build scheduled with the buildbot fleet by @encukou for commit b6082ac 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F144666%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
encukou
left a comment
There was a problem hiding this comment.
Thanks!
Let's wait for buildbots; they've been grumpy about test_c[pp]ext lately.
|
Merged. Thanks for the review @encukou. |
The PEP 810 implementation introduced a minor incompatibility. It has been fixed quickly by commit 7854597. typedef enum {
PyImport_LAZY_NORMAL,
PyImport_LAZY_ALL,
- PyImport_LAZY_NONE,
+ PyImport_LAZY_NONE
} PyImport_LazyImportsMode;The buildbot tests passed successfully on this PR ;-) |
If the _Py_TYPEOF macro is not available, include <string.h> to get memcpy() for the Py_CLEAR() macro. The limited C API version 3.11 and newer doesn't include <string.h> anymore.
Add a Py_CLEAR() test in test_cext.
Modify also _Py_TYPEOF to use C23 typeof() if available.
memcpy()usage without#include <string.h>inpwdmodule.c#121617